elf32-mips.c 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632
  1. /* MIPS-specific support for 32-bit ELF
  2. Copyright (C) 1993-2015 Free Software Foundation, Inc.
  3. Most of the information added by Ian Lance Taylor, Cygnus Support,
  4. <ian@cygnus.com>.
  5. N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC.
  6. <mark@codesourcery.com>
  7. Traditional MIPS targets support added by Koundinya.K, Dansk Data
  8. Elektronik & Operations Research Group. <kk@ddeorg.soft.net>
  9. This file is part of BFD, the Binary File Descriptor library.
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 3 of the License, or
  13. (at your option) any later version.
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. GNU General Public License for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with this program; if not, write to the Free Software
  20. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  21. MA 02110-1301, USA. */
  22. /* This file handles MIPS ELF targets. SGI Irix 5 uses a slightly
  23. different MIPS ELF from other targets. This matters when linking.
  24. This file supports both, switching at runtime. */
  25. #include "sysdep.h"
  26. #include "bfd.h"
  27. #include "libbfd.h"
  28. #include "bfdlink.h"
  29. #include "genlink.h"
  30. #include "elf-bfd.h"
  31. #include "elfxx-mips.h"
  32. #include "elf/mips.h"
  33. #include "elf-vxworks.h"
  34. /* Get the ECOFF swapping routines. */
  35. #include "coff/sym.h"
  36. #include "coff/symconst.h"
  37. #include "coff/internal.h"
  38. #include "coff/ecoff.h"
  39. #include "coff/mips.h"
  40. #define ECOFF_SIGNED_32
  41. #include "ecoffswap.h"
  42. static bfd_reloc_status_type gprel32_with_gp
  43. (bfd *, asymbol *, arelent *, asection *, bfd_boolean, void *, bfd_vma);
  44. static bfd_reloc_status_type mips_elf_gprel32_reloc
  45. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  46. static bfd_reloc_status_type mips32_64bit_reloc
  47. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  48. static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
  49. (bfd *, bfd_reloc_code_real_type);
  50. static reloc_howto_type *mips_elf32_rtype_to_howto
  51. (unsigned int, bfd_boolean);
  52. static void mips_info_to_howto_rel
  53. (bfd *, arelent *, Elf_Internal_Rela *);
  54. static void mips_info_to_howto_rela
  55. (bfd *, arelent *, Elf_Internal_Rela *);
  56. static bfd_boolean mips_elf_sym_is_global
  57. (bfd *, asymbol *);
  58. static bfd_boolean mips_elf32_object_p
  59. (bfd *);
  60. static bfd_boolean mips_elf_is_local_label_name
  61. (bfd *, const char *);
  62. static bfd_reloc_status_type mips16_gprel_reloc
  63. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  64. static bfd_reloc_status_type mips_elf_final_gp
  65. (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *);
  66. static bfd_boolean mips_elf_assign_gp
  67. (bfd *, bfd_vma *);
  68. static bfd_boolean elf32_mips_grok_prstatus
  69. (bfd *, Elf_Internal_Note *);
  70. static bfd_boolean elf32_mips_grok_psinfo
  71. (bfd *, Elf_Internal_Note *);
  72. static irix_compat_t elf32_mips_irix_compat
  73. (bfd *);
  74. extern const bfd_target mips_elf32_be_vec;
  75. extern const bfd_target mips_elf32_le_vec;
  76. /* Nonzero if ABFD is using the N32 ABI. */
  77. #define ABI_N32_P(abfd) \
  78. ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
  79. /* Whether we are trying to be compatible with IRIX at all. */
  80. #define SGI_COMPAT(abfd) \
  81. (elf32_mips_irix_compat (abfd) != ict_none)
  82. /* The number of local .got entries we reserve. */
  83. #define MIPS_RESERVED_GOTNO (2)
  84. /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
  85. from smaller values. Start with zero, widen, *then* decrement. */
  86. #define MINUS_ONE (((bfd_vma)0) - 1)
  87. /* The relocation table used for SHT_REL sections. */
  88. static reloc_howto_type elf_mips_howto_table_rel[] =
  89. {
  90. /* No relocation. */
  91. HOWTO (R_MIPS_NONE, /* type */
  92. 0, /* rightshift */
  93. 3, /* size (0 = byte, 1 = short, 2 = long) */
  94. 0, /* bitsize */
  95. FALSE, /* pc_relative */
  96. 0, /* bitpos */
  97. complain_overflow_dont, /* complain_on_overflow */
  98. _bfd_mips_elf_generic_reloc, /* special_function */
  99. "R_MIPS_NONE", /* name */
  100. FALSE, /* partial_inplace */
  101. 0, /* src_mask */
  102. 0, /* dst_mask */
  103. FALSE), /* pcrel_offset */
  104. /* 16 bit relocation. */
  105. HOWTO (R_MIPS_16, /* type */
  106. 0, /* rightshift */
  107. 2, /* size (0 = byte, 1 = short, 2 = long) */
  108. 16, /* bitsize */
  109. FALSE, /* pc_relative */
  110. 0, /* bitpos */
  111. complain_overflow_signed, /* complain_on_overflow */
  112. _bfd_mips_elf_generic_reloc, /* special_function */
  113. "R_MIPS_16", /* name */
  114. TRUE, /* partial_inplace */
  115. 0x0000ffff, /* src_mask */
  116. 0x0000ffff, /* dst_mask */
  117. FALSE), /* pcrel_offset */
  118. /* 32 bit relocation. */
  119. HOWTO (R_MIPS_32, /* type */
  120. 0, /* rightshift */
  121. 2, /* size (0 = byte, 1 = short, 2 = long) */
  122. 32, /* bitsize */
  123. FALSE, /* pc_relative */
  124. 0, /* bitpos */
  125. complain_overflow_dont, /* complain_on_overflow */
  126. _bfd_mips_elf_generic_reloc, /* special_function */
  127. "R_MIPS_32", /* name */
  128. TRUE, /* partial_inplace */
  129. 0xffffffff, /* src_mask */
  130. 0xffffffff, /* dst_mask */
  131. FALSE), /* pcrel_offset */
  132. /* 32 bit symbol relative relocation. */
  133. HOWTO (R_MIPS_REL32, /* type */
  134. 0, /* rightshift */
  135. 2, /* size (0 = byte, 1 = short, 2 = long) */
  136. 32, /* bitsize */
  137. FALSE, /* pc_relative */
  138. 0, /* bitpos */
  139. complain_overflow_dont, /* complain_on_overflow */
  140. _bfd_mips_elf_generic_reloc, /* special_function */
  141. "R_MIPS_REL32", /* name */
  142. TRUE, /* partial_inplace */
  143. 0xffffffff, /* src_mask */
  144. 0xffffffff, /* dst_mask */
  145. FALSE), /* pcrel_offset */
  146. /* 26 bit jump address. */
  147. HOWTO (R_MIPS_26, /* type */
  148. 2, /* rightshift */
  149. 2, /* size (0 = byte, 1 = short, 2 = long) */
  150. 26, /* bitsize */
  151. FALSE, /* pc_relative */
  152. 0, /* bitpos */
  153. complain_overflow_dont, /* complain_on_overflow */
  154. /* This needs complex overflow
  155. detection, because the upper four
  156. bits must match the PC + 4. */
  157. _bfd_mips_elf_generic_reloc, /* special_function */
  158. "R_MIPS_26", /* name */
  159. TRUE, /* partial_inplace */
  160. 0x03ffffff, /* src_mask */
  161. 0x03ffffff, /* dst_mask */
  162. FALSE), /* pcrel_offset */
  163. /* High 16 bits of symbol value. */
  164. HOWTO (R_MIPS_HI16, /* type */
  165. 16, /* rightshift */
  166. 2, /* size (0 = byte, 1 = short, 2 = long) */
  167. 16, /* bitsize */
  168. FALSE, /* pc_relative */
  169. 0, /* bitpos */
  170. complain_overflow_dont, /* complain_on_overflow */
  171. _bfd_mips_elf_hi16_reloc, /* special_function */
  172. "R_MIPS_HI16", /* name */
  173. TRUE, /* partial_inplace */
  174. 0x0000ffff, /* src_mask */
  175. 0x0000ffff, /* dst_mask */
  176. FALSE), /* pcrel_offset */
  177. /* Low 16 bits of symbol value. */
  178. HOWTO (R_MIPS_LO16, /* type */
  179. 0, /* rightshift */
  180. 2, /* size (0 = byte, 1 = short, 2 = long) */
  181. 16, /* bitsize */
  182. FALSE, /* pc_relative */
  183. 0, /* bitpos */
  184. complain_overflow_dont, /* complain_on_overflow */
  185. _bfd_mips_elf_lo16_reloc, /* special_function */
  186. "R_MIPS_LO16", /* name */
  187. TRUE, /* partial_inplace */
  188. 0x0000ffff, /* src_mask */
  189. 0x0000ffff, /* dst_mask */
  190. FALSE), /* pcrel_offset */
  191. /* GP relative reference. */
  192. HOWTO (R_MIPS_GPREL16, /* type */
  193. 0, /* rightshift */
  194. 2, /* size (0 = byte, 1 = short, 2 = long) */
  195. 16, /* bitsize */
  196. FALSE, /* pc_relative */
  197. 0, /* bitpos */
  198. complain_overflow_signed, /* complain_on_overflow */
  199. _bfd_mips_elf32_gprel16_reloc, /* special_function */
  200. "R_MIPS_GPREL16", /* name */
  201. TRUE, /* partial_inplace */
  202. 0x0000ffff, /* src_mask */
  203. 0x0000ffff, /* dst_mask */
  204. FALSE), /* pcrel_offset */
  205. /* Reference to literal section. */
  206. HOWTO (R_MIPS_LITERAL, /* type */
  207. 0, /* rightshift */
  208. 2, /* size (0 = byte, 1 = short, 2 = long) */
  209. 16, /* bitsize */
  210. FALSE, /* pc_relative */
  211. 0, /* bitpos */
  212. complain_overflow_signed, /* complain_on_overflow */
  213. _bfd_mips_elf32_gprel16_reloc, /* special_function */
  214. "R_MIPS_LITERAL", /* name */
  215. TRUE, /* partial_inplace */
  216. 0x0000ffff, /* src_mask */
  217. 0x0000ffff, /* dst_mask */
  218. FALSE), /* pcrel_offset */
  219. /* Reference to global offset table. */
  220. HOWTO (R_MIPS_GOT16, /* type */
  221. 0, /* rightshift */
  222. 2, /* size (0 = byte, 1 = short, 2 = long) */
  223. 16, /* bitsize */
  224. FALSE, /* pc_relative */
  225. 0, /* bitpos */
  226. complain_overflow_signed, /* complain_on_overflow */
  227. _bfd_mips_elf_got16_reloc, /* special_function */
  228. "R_MIPS_GOT16", /* name */
  229. TRUE, /* partial_inplace */
  230. 0x0000ffff, /* src_mask */
  231. 0x0000ffff, /* dst_mask */
  232. FALSE), /* pcrel_offset */
  233. /* 16 bit PC relative reference. Note that the ABI document has a typo
  234. and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
  235. We do the right thing here. */
  236. HOWTO (R_MIPS_PC16, /* type */
  237. 2, /* rightshift */
  238. 2, /* size (0 = byte, 1 = short, 2 = long) */
  239. 16, /* bitsize */
  240. TRUE, /* pc_relative */
  241. 0, /* bitpos */
  242. complain_overflow_signed, /* complain_on_overflow */
  243. _bfd_mips_elf_generic_reloc, /* special_function */
  244. "R_MIPS_PC16", /* name */
  245. TRUE, /* partial_inplace */
  246. 0x0000ffff, /* src_mask */
  247. 0x0000ffff, /* dst_mask */
  248. TRUE), /* pcrel_offset */
  249. /* 16 bit call through global offset table. */
  250. HOWTO (R_MIPS_CALL16, /* type */
  251. 0, /* rightshift */
  252. 2, /* size (0 = byte, 1 = short, 2 = long) */
  253. 16, /* bitsize */
  254. FALSE, /* pc_relative */
  255. 0, /* bitpos */
  256. complain_overflow_signed, /* complain_on_overflow */
  257. _bfd_mips_elf_generic_reloc, /* special_function */
  258. "R_MIPS_CALL16", /* name */
  259. TRUE, /* partial_inplace */
  260. 0x0000ffff, /* src_mask */
  261. 0x0000ffff, /* dst_mask */
  262. FALSE), /* pcrel_offset */
  263. /* 32 bit GP relative reference. */
  264. HOWTO (R_MIPS_GPREL32, /* type */
  265. 0, /* rightshift */
  266. 2, /* size (0 = byte, 1 = short, 2 = long) */
  267. 32, /* bitsize */
  268. FALSE, /* pc_relative */
  269. 0, /* bitpos */
  270. complain_overflow_dont, /* complain_on_overflow */
  271. mips_elf_gprel32_reloc, /* special_function */
  272. "R_MIPS_GPREL32", /* name */
  273. TRUE, /* partial_inplace */
  274. 0xffffffff, /* src_mask */
  275. 0xffffffff, /* dst_mask */
  276. FALSE), /* pcrel_offset */
  277. /* The remaining relocs are defined on Irix 5, although they are
  278. not defined by the ABI. */
  279. EMPTY_HOWTO (13),
  280. EMPTY_HOWTO (14),
  281. EMPTY_HOWTO (15),
  282. /* A 5 bit shift field. */
  283. HOWTO (R_MIPS_SHIFT5, /* type */
  284. 0, /* rightshift */
  285. 2, /* size (0 = byte, 1 = short, 2 = long) */
  286. 5, /* bitsize */
  287. FALSE, /* pc_relative */
  288. 6, /* bitpos */
  289. complain_overflow_bitfield, /* complain_on_overflow */
  290. _bfd_mips_elf_generic_reloc, /* special_function */
  291. "R_MIPS_SHIFT5", /* name */
  292. TRUE, /* partial_inplace */
  293. 0x000007c0, /* src_mask */
  294. 0x000007c0, /* dst_mask */
  295. FALSE), /* pcrel_offset */
  296. /* A 6 bit shift field. */
  297. /* FIXME: This is not handled correctly; a special function is
  298. needed to put the most significant bit in the right place. */
  299. HOWTO (R_MIPS_SHIFT6, /* type */
  300. 0, /* rightshift */
  301. 2, /* size (0 = byte, 1 = short, 2 = long) */
  302. 6, /* bitsize */
  303. FALSE, /* pc_relative */
  304. 6, /* bitpos */
  305. complain_overflow_bitfield, /* complain_on_overflow */
  306. _bfd_mips_elf_generic_reloc, /* special_function */
  307. "R_MIPS_SHIFT6", /* name */
  308. TRUE, /* partial_inplace */
  309. 0x000007c4, /* src_mask */
  310. 0x000007c4, /* dst_mask */
  311. FALSE), /* pcrel_offset */
  312. /* A 64 bit relocation. */
  313. HOWTO (R_MIPS_64, /* type */
  314. 0, /* rightshift */
  315. 4, /* size (0 = byte, 1 = short, 2 = long) */
  316. 64, /* bitsize */
  317. FALSE, /* pc_relative */
  318. 0, /* bitpos */
  319. complain_overflow_dont, /* complain_on_overflow */
  320. mips32_64bit_reloc, /* special_function */
  321. "R_MIPS_64", /* name */
  322. TRUE, /* partial_inplace */
  323. MINUS_ONE, /* src_mask */
  324. MINUS_ONE, /* dst_mask */
  325. FALSE), /* pcrel_offset */
  326. /* Displacement in the global offset table. */
  327. HOWTO (R_MIPS_GOT_DISP, /* type */
  328. 0, /* rightshift */
  329. 2, /* size (0 = byte, 1 = short, 2 = long) */
  330. 16, /* bitsize */
  331. FALSE, /* pc_relative */
  332. 0, /* bitpos */
  333. complain_overflow_signed, /* complain_on_overflow */
  334. _bfd_mips_elf_generic_reloc, /* special_function */
  335. "R_MIPS_GOT_DISP", /* name */
  336. TRUE, /* partial_inplace */
  337. 0x0000ffff, /* src_mask */
  338. 0x0000ffff, /* dst_mask */
  339. FALSE), /* pcrel_offset */
  340. /* Displacement to page pointer in the global offset table. */
  341. HOWTO (R_MIPS_GOT_PAGE, /* type */
  342. 0, /* rightshift */
  343. 2, /* size (0 = byte, 1 = short, 2 = long) */
  344. 16, /* bitsize */
  345. FALSE, /* pc_relative */
  346. 0, /* bitpos */
  347. complain_overflow_signed, /* complain_on_overflow */
  348. _bfd_mips_elf_generic_reloc, /* special_function */
  349. "R_MIPS_GOT_PAGE", /* name */
  350. TRUE, /* partial_inplace */
  351. 0x0000ffff, /* src_mask */
  352. 0x0000ffff, /* dst_mask */
  353. FALSE), /* pcrel_offset */
  354. /* Offset from page pointer in the global offset table. */
  355. HOWTO (R_MIPS_GOT_OFST, /* type */
  356. 0, /* rightshift */
  357. 2, /* size (0 = byte, 1 = short, 2 = long) */
  358. 16, /* bitsize */
  359. FALSE, /* pc_relative */
  360. 0, /* bitpos */
  361. complain_overflow_signed, /* complain_on_overflow */
  362. _bfd_mips_elf_generic_reloc, /* special_function */
  363. "R_MIPS_GOT_OFST", /* name */
  364. TRUE, /* partial_inplace */
  365. 0x0000ffff, /* src_mask */
  366. 0x0000ffff, /* dst_mask */
  367. FALSE), /* pcrel_offset */
  368. /* High 16 bits of displacement in global offset table. */
  369. HOWTO (R_MIPS_GOT_HI16, /* type */
  370. 0, /* rightshift */
  371. 2, /* size (0 = byte, 1 = short, 2 = long) */
  372. 16, /* bitsize */
  373. FALSE, /* pc_relative */
  374. 0, /* bitpos */
  375. complain_overflow_dont, /* complain_on_overflow */
  376. _bfd_mips_elf_generic_reloc, /* special_function */
  377. "R_MIPS_GOT_HI16", /* name */
  378. TRUE, /* partial_inplace */
  379. 0x0000ffff, /* src_mask */
  380. 0x0000ffff, /* dst_mask */
  381. FALSE), /* pcrel_offset */
  382. /* Low 16 bits of displacement in global offset table. */
  383. HOWTO (R_MIPS_GOT_LO16, /* type */
  384. 0, /* rightshift */
  385. 2, /* size (0 = byte, 1 = short, 2 = long) */
  386. 16, /* bitsize */
  387. FALSE, /* pc_relative */
  388. 0, /* bitpos */
  389. complain_overflow_dont, /* complain_on_overflow */
  390. _bfd_mips_elf_generic_reloc, /* special_function */
  391. "R_MIPS_GOT_LO16", /* name */
  392. TRUE, /* partial_inplace */
  393. 0x0000ffff, /* src_mask */
  394. 0x0000ffff, /* dst_mask */
  395. FALSE), /* pcrel_offset */
  396. /* 64 bit subtraction. Used in the N32 ABI. */
  397. HOWTO (R_MIPS_SUB, /* type */
  398. 0, /* rightshift */
  399. 4, /* size (0 = byte, 1 = short, 2 = long) */
  400. 64, /* bitsize */
  401. FALSE, /* pc_relative */
  402. 0, /* bitpos */
  403. complain_overflow_dont, /* complain_on_overflow */
  404. _bfd_mips_elf_generic_reloc, /* special_function */
  405. "R_MIPS_SUB", /* name */
  406. TRUE, /* partial_inplace */
  407. MINUS_ONE, /* src_mask */
  408. MINUS_ONE, /* dst_mask */
  409. FALSE), /* pcrel_offset */
  410. /* Used to cause the linker to insert and delete instructions? */
  411. EMPTY_HOWTO (R_MIPS_INSERT_A),
  412. EMPTY_HOWTO (R_MIPS_INSERT_B),
  413. EMPTY_HOWTO (R_MIPS_DELETE),
  414. /* Get the higher value of a 64 bit addend. */
  415. HOWTO (R_MIPS_HIGHER, /* type */
  416. 0, /* rightshift */
  417. 2, /* size (0 = byte, 1 = short, 2 = long) */
  418. 16, /* bitsize */
  419. FALSE, /* pc_relative */
  420. 0, /* bitpos */
  421. complain_overflow_dont, /* complain_on_overflow */
  422. _bfd_mips_elf_generic_reloc, /* special_function */
  423. "R_MIPS_HIGHER", /* name */
  424. TRUE, /* partial_inplace */
  425. 0x0000ffff, /* src_mask */
  426. 0x0000ffff, /* dst_mask */
  427. FALSE), /* pcrel_offset */
  428. /* Get the highest value of a 64 bit addend. */
  429. HOWTO (R_MIPS_HIGHEST, /* type */
  430. 0, /* rightshift */
  431. 2, /* size (0 = byte, 1 = short, 2 = long) */
  432. 16, /* bitsize */
  433. FALSE, /* pc_relative */
  434. 0, /* bitpos */
  435. complain_overflow_dont, /* complain_on_overflow */
  436. _bfd_mips_elf_generic_reloc, /* special_function */
  437. "R_MIPS_HIGHEST", /* name */
  438. TRUE, /* partial_inplace */
  439. 0x0000ffff, /* src_mask */
  440. 0x0000ffff, /* dst_mask */
  441. FALSE), /* pcrel_offset */
  442. /* High 16 bits of displacement in global offset table. */
  443. HOWTO (R_MIPS_CALL_HI16, /* type */
  444. 0, /* rightshift */
  445. 2, /* size (0 = byte, 1 = short, 2 = long) */
  446. 16, /* bitsize */
  447. FALSE, /* pc_relative */
  448. 0, /* bitpos */
  449. complain_overflow_dont, /* complain_on_overflow */
  450. _bfd_mips_elf_generic_reloc, /* special_function */
  451. "R_MIPS_CALL_HI16", /* name */
  452. TRUE, /* partial_inplace */
  453. 0x0000ffff, /* src_mask */
  454. 0x0000ffff, /* dst_mask */
  455. FALSE), /* pcrel_offset */
  456. /* Low 16 bits of displacement in global offset table. */
  457. HOWTO (R_MIPS_CALL_LO16, /* type */
  458. 0, /* rightshift */
  459. 2, /* size (0 = byte, 1 = short, 2 = long) */
  460. 16, /* bitsize */
  461. FALSE, /* pc_relative */
  462. 0, /* bitpos */
  463. complain_overflow_dont, /* complain_on_overflow */
  464. _bfd_mips_elf_generic_reloc, /* special_function */
  465. "R_MIPS_CALL_LO16", /* name */
  466. TRUE, /* partial_inplace */
  467. 0x0000ffff, /* src_mask */
  468. 0x0000ffff, /* dst_mask */
  469. FALSE), /* pcrel_offset */
  470. /* Section displacement. */
  471. HOWTO (R_MIPS_SCN_DISP, /* type */
  472. 0, /* rightshift */
  473. 2, /* size (0 = byte, 1 = short, 2 = long) */
  474. 32, /* bitsize */
  475. FALSE, /* pc_relative */
  476. 0, /* bitpos */
  477. complain_overflow_dont, /* complain_on_overflow */
  478. _bfd_mips_elf_generic_reloc, /* special_function */
  479. "R_MIPS_SCN_DISP", /* name */
  480. TRUE, /* partial_inplace */
  481. 0xffffffff, /* src_mask */
  482. 0xffffffff, /* dst_mask */
  483. FALSE), /* pcrel_offset */
  484. EMPTY_HOWTO (R_MIPS_REL16),
  485. EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
  486. EMPTY_HOWTO (R_MIPS_PJUMP),
  487. EMPTY_HOWTO (R_MIPS_RELGOT),
  488. /* Protected jump conversion. This is an optimization hint. No
  489. relocation is required for correctness. */
  490. HOWTO (R_MIPS_JALR, /* type */
  491. 0, /* rightshift */
  492. 2, /* size (0 = byte, 1 = short, 2 = long) */
  493. 32, /* bitsize */
  494. FALSE, /* pc_relative */
  495. 0, /* bitpos */
  496. complain_overflow_dont, /* complain_on_overflow */
  497. _bfd_mips_elf_generic_reloc, /* special_function */
  498. "R_MIPS_JALR", /* name */
  499. FALSE, /* partial_inplace */
  500. 0x00000000, /* src_mask */
  501. 0x00000000, /* dst_mask */
  502. FALSE), /* pcrel_offset */
  503. /* TLS GD/LD dynamic relocations. */
  504. HOWTO (R_MIPS_TLS_DTPMOD32, /* type */
  505. 0, /* rightshift */
  506. 2, /* size (0 = byte, 1 = short, 2 = long) */
  507. 32, /* bitsize */
  508. FALSE, /* pc_relative */
  509. 0, /* bitpos */
  510. complain_overflow_dont, /* complain_on_overflow */
  511. _bfd_mips_elf_generic_reloc, /* special_function */
  512. "R_MIPS_TLS_DTPMOD32", /* name */
  513. TRUE, /* partial_inplace */
  514. 0xffffffff, /* src_mask */
  515. 0xffffffff, /* dst_mask */
  516. FALSE), /* pcrel_offset */
  517. HOWTO (R_MIPS_TLS_DTPREL32, /* type */
  518. 0, /* rightshift */
  519. 2, /* size (0 = byte, 1 = short, 2 = long) */
  520. 32, /* bitsize */
  521. FALSE, /* pc_relative */
  522. 0, /* bitpos */
  523. complain_overflow_dont, /* complain_on_overflow */
  524. _bfd_mips_elf_generic_reloc, /* special_function */
  525. "R_MIPS_TLS_DTPREL32", /* name */
  526. TRUE, /* partial_inplace */
  527. 0xffffffff, /* src_mask */
  528. 0xffffffff, /* dst_mask */
  529. FALSE), /* pcrel_offset */
  530. EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
  531. EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
  532. /* TLS general dynamic variable reference. */
  533. HOWTO (R_MIPS_TLS_GD, /* type */
  534. 0, /* rightshift */
  535. 2, /* size (0 = byte, 1 = short, 2 = long) */
  536. 16, /* bitsize */
  537. FALSE, /* pc_relative */
  538. 0, /* bitpos */
  539. complain_overflow_signed, /* complain_on_overflow */
  540. _bfd_mips_elf_generic_reloc, /* special_function */
  541. "R_MIPS_TLS_GD", /* name */
  542. TRUE, /* partial_inplace */
  543. 0x0000ffff, /* src_mask */
  544. 0x0000ffff, /* dst_mask */
  545. FALSE), /* pcrel_offset */
  546. /* TLS local dynamic variable reference. */
  547. HOWTO (R_MIPS_TLS_LDM, /* type */
  548. 0, /* rightshift */
  549. 2, /* size (0 = byte, 1 = short, 2 = long) */
  550. 16, /* bitsize */
  551. FALSE, /* pc_relative */
  552. 0, /* bitpos */
  553. complain_overflow_signed, /* complain_on_overflow */
  554. _bfd_mips_elf_generic_reloc, /* special_function */
  555. "R_MIPS_TLS_LDM", /* name */
  556. TRUE, /* partial_inplace */
  557. 0x0000ffff, /* src_mask */
  558. 0x0000ffff, /* dst_mask */
  559. FALSE), /* pcrel_offset */
  560. /* TLS local dynamic offset. */
  561. HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */
  562. 0, /* rightshift */
  563. 2, /* size (0 = byte, 1 = short, 2 = long) */
  564. 16, /* bitsize */
  565. FALSE, /* pc_relative */
  566. 0, /* bitpos */
  567. complain_overflow_signed, /* complain_on_overflow */
  568. _bfd_mips_elf_generic_reloc, /* special_function */
  569. "R_MIPS_TLS_DTPREL_HI16", /* name */
  570. TRUE, /* partial_inplace */
  571. 0x0000ffff, /* src_mask */
  572. 0x0000ffff, /* dst_mask */
  573. FALSE), /* pcrel_offset */
  574. /* TLS local dynamic offset. */
  575. HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */
  576. 0, /* rightshift */
  577. 2, /* size (0 = byte, 1 = short, 2 = long) */
  578. 16, /* bitsize */
  579. FALSE, /* pc_relative */
  580. 0, /* bitpos */
  581. complain_overflow_signed, /* complain_on_overflow */
  582. _bfd_mips_elf_generic_reloc, /* special_function */
  583. "R_MIPS_TLS_DTPREL_LO16", /* name */
  584. TRUE, /* partial_inplace */
  585. 0x0000ffff, /* src_mask */
  586. 0x0000ffff, /* dst_mask */
  587. FALSE), /* pcrel_offset */
  588. /* TLS thread pointer offset. */
  589. HOWTO (R_MIPS_TLS_GOTTPREL, /* type */
  590. 0, /* rightshift */
  591. 2, /* size (0 = byte, 1 = short, 2 = long) */
  592. 16, /* bitsize */
  593. FALSE, /* pc_relative */
  594. 0, /* bitpos */
  595. complain_overflow_signed, /* complain_on_overflow */
  596. _bfd_mips_elf_generic_reloc, /* special_function */
  597. "R_MIPS_TLS_GOTTPREL", /* name */
  598. TRUE, /* partial_inplace */
  599. 0x0000ffff, /* src_mask */
  600. 0x0000ffff, /* dst_mask */
  601. FALSE), /* pcrel_offset */
  602. /* TLS IE dynamic relocations. */
  603. HOWTO (R_MIPS_TLS_TPREL32, /* type */
  604. 0, /* rightshift */
  605. 2, /* size (0 = byte, 1 = short, 2 = long) */
  606. 32, /* bitsize */
  607. FALSE, /* pc_relative */
  608. 0, /* bitpos */
  609. complain_overflow_dont, /* complain_on_overflow */
  610. _bfd_mips_elf_generic_reloc, /* special_function */
  611. "R_MIPS_TLS_TPREL32", /* name */
  612. TRUE, /* partial_inplace */
  613. 0xffffffff, /* src_mask */
  614. 0xffffffff, /* dst_mask */
  615. FALSE), /* pcrel_offset */
  616. EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
  617. /* TLS thread pointer offset. */
  618. HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */
  619. 0, /* rightshift */
  620. 2, /* size (0 = byte, 1 = short, 2 = long) */
  621. 16, /* bitsize */
  622. FALSE, /* pc_relative */
  623. 0, /* bitpos */
  624. complain_overflow_signed, /* complain_on_overflow */
  625. _bfd_mips_elf_generic_reloc, /* special_function */
  626. "R_MIPS_TLS_TPREL_HI16", /* name */
  627. TRUE, /* partial_inplace */
  628. 0x0000ffff, /* src_mask */
  629. 0x0000ffff, /* dst_mask */
  630. FALSE), /* pcrel_offset */
  631. /* TLS thread pointer offset. */
  632. HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */
  633. 0, /* rightshift */
  634. 2, /* size (0 = byte, 1 = short, 2 = long) */
  635. 16, /* bitsize */
  636. FALSE, /* pc_relative */
  637. 0, /* bitpos */
  638. complain_overflow_signed, /* complain_on_overflow */
  639. _bfd_mips_elf_generic_reloc, /* special_function */
  640. "R_MIPS_TLS_TPREL_LO16", /* name */
  641. TRUE, /* partial_inplace */
  642. 0x0000ffff, /* src_mask */
  643. 0x0000ffff, /* dst_mask */
  644. FALSE), /* pcrel_offset */
  645. /* 32 bit relocation with no addend. */
  646. HOWTO (R_MIPS_GLOB_DAT, /* type */
  647. 0, /* rightshift */
  648. 2, /* size (0 = byte, 1 = short, 2 = long) */
  649. 32, /* bitsize */
  650. FALSE, /* pc_relative */
  651. 0, /* bitpos */
  652. complain_overflow_dont, /* complain_on_overflow */
  653. _bfd_mips_elf_generic_reloc, /* special_function */
  654. "R_MIPS_GLOB_DAT", /* name */
  655. FALSE, /* partial_inplace */
  656. 0x0, /* src_mask */
  657. 0xffffffff, /* dst_mask */
  658. FALSE), /* pcrel_offset */
  659. EMPTY_HOWTO (52),
  660. EMPTY_HOWTO (53),
  661. EMPTY_HOWTO (54),
  662. EMPTY_HOWTO (55),
  663. EMPTY_HOWTO (56),
  664. EMPTY_HOWTO (57),
  665. EMPTY_HOWTO (58),
  666. EMPTY_HOWTO (59),
  667. HOWTO (R_MIPS_PC21_S2, /* type */
  668. 2, /* rightshift */
  669. 2, /* size (0 = byte, 1 = short, 2 = long) */
  670. 21, /* bitsize */
  671. TRUE, /* pc_relative */
  672. 0, /* bitpos */
  673. complain_overflow_signed, /* complain_on_overflow */
  674. _bfd_mips_elf_generic_reloc, /* special_function */
  675. "R_MIPS_PC21_S2", /* name */
  676. TRUE, /* partial_inplace */
  677. 0x001fffff, /* src_mask */
  678. 0x001fffff, /* dst_mask */
  679. TRUE), /* pcrel_offset */
  680. HOWTO (R_MIPS_PC26_S2, /* type */
  681. 2, /* rightshift */
  682. 2, /* size (0 = byte, 1 = short, 2 = long) */
  683. 26, /* bitsize */
  684. TRUE, /* pc_relative */
  685. 0, /* bitpos */
  686. complain_overflow_signed, /* complain_on_overflow */
  687. _bfd_mips_elf_generic_reloc, /* special_function */
  688. "R_MIPS_PC26_S2", /* name */
  689. TRUE, /* partial_inplace */
  690. 0x03ffffff, /* src_mask */
  691. 0x03ffffff, /* dst_mask */
  692. TRUE), /* pcrel_offset */
  693. HOWTO (R_MIPS_PC18_S3, /* type */
  694. 3, /* rightshift */
  695. 2, /* size (0 = byte, 1 = short, 2 = long) */
  696. 18, /* bitsize */
  697. TRUE, /* pc_relative */
  698. 0, /* bitpos */
  699. complain_overflow_signed, /* complain_on_overflow */
  700. _bfd_mips_elf_generic_reloc, /* special_function */
  701. "R_MIPS_PC18_S3", /* name */
  702. TRUE, /* partial_inplace */
  703. 0x0003ffff, /* src_mask */
  704. 0x0003ffff, /* dst_mask */
  705. TRUE), /* pcrel_offset */
  706. HOWTO (R_MIPS_PC19_S2, /* type */
  707. 2, /* rightshift */
  708. 2, /* size (0 = byte, 1 = short, 2 = long) */
  709. 19, /* bitsize */
  710. TRUE, /* pc_relative */
  711. 0, /* bitpos */
  712. complain_overflow_signed, /* complain_on_overflow */
  713. _bfd_mips_elf_generic_reloc, /* special_function */
  714. "R_MIPS_PC19_S2", /* name */
  715. TRUE, /* partial_inplace */
  716. 0x0007ffff, /* src_mask */
  717. 0x0007ffff, /* dst_mask */
  718. TRUE), /* pcrel_offset */
  719. HOWTO (R_MIPS_PCHI16, /* type */
  720. 16, /* rightshift */
  721. 2, /* size (0 = byte, 1 = short, 2 = long) */
  722. 16, /* bitsize */
  723. TRUE, /* pc_relative */
  724. 0, /* bitpos */
  725. complain_overflow_signed, /* complain_on_overflow */
  726. _bfd_mips_elf_generic_reloc, /* special_function */
  727. "R_MIPS_PCHI16", /* name */
  728. TRUE, /* partial_inplace */
  729. 0x0000ffff, /* src_mask */
  730. 0x0000ffff, /* dst_mask */
  731. TRUE), /* pcrel_offset */
  732. HOWTO (R_MIPS_PCLO16, /* type */
  733. 0, /* rightshift */
  734. 2, /* size (0 = byte, 1 = short, 2 = long) */
  735. 16, /* bitsize */
  736. TRUE, /* pc_relative */
  737. 0, /* bitpos */
  738. complain_overflow_dont, /* complain_on_overflow */
  739. _bfd_mips_elf_generic_reloc, /* special_function */
  740. "R_MIPS_PCLO16", /* name */
  741. TRUE, /* partial_inplace */
  742. 0x0000ffff, /* src_mask */
  743. 0x0000ffff, /* dst_mask */
  744. TRUE), /* pcrel_offset */
  745. };
  746. /* The reloc used for BFD_RELOC_CTOR when doing a 64 bit link. This
  747. is a hack to make the linker think that we need 64 bit values. */
  748. static reloc_howto_type elf_mips_ctor64_howto =
  749. HOWTO (R_MIPS_64, /* type */
  750. 0, /* rightshift */
  751. 4, /* size (0 = byte, 1 = short, 2 = long) */
  752. 32, /* bitsize */
  753. FALSE, /* pc_relative */
  754. 0, /* bitpos */
  755. complain_overflow_signed, /* complain_on_overflow */
  756. mips32_64bit_reloc, /* special_function */
  757. "R_MIPS_64", /* name */
  758. TRUE, /* partial_inplace */
  759. 0xffffffff, /* src_mask */
  760. 0xffffffff, /* dst_mask */
  761. FALSE); /* pcrel_offset */
  762. static reloc_howto_type elf_mips16_howto_table_rel[] =
  763. {
  764. /* The reloc used for the mips16 jump instruction. */
  765. HOWTO (R_MIPS16_26, /* type */
  766. 2, /* rightshift */
  767. 2, /* size (0 = byte, 1 = short, 2 = long) */
  768. 26, /* bitsize */
  769. FALSE, /* pc_relative */
  770. 0, /* bitpos */
  771. complain_overflow_dont, /* complain_on_overflow */
  772. /* This needs complex overflow
  773. detection, because the upper four
  774. bits must match the PC. */
  775. _bfd_mips_elf_generic_reloc, /* special_function */
  776. "R_MIPS16_26", /* name */
  777. TRUE, /* partial_inplace */
  778. 0x3ffffff, /* src_mask */
  779. 0x3ffffff, /* dst_mask */
  780. FALSE), /* pcrel_offset */
  781. /* The reloc used for the mips16 gprel instruction. */
  782. HOWTO (R_MIPS16_GPREL, /* type */
  783. 0, /* rightshift */
  784. 2, /* size (0 = byte, 1 = short, 2 = long) */
  785. 16, /* bitsize */
  786. FALSE, /* pc_relative */
  787. 0, /* bitpos */
  788. complain_overflow_signed, /* complain_on_overflow */
  789. mips16_gprel_reloc, /* special_function */
  790. "R_MIPS16_GPREL", /* name */
  791. TRUE, /* partial_inplace */
  792. 0x0000ffff, /* src_mask */
  793. 0x0000ffff, /* dst_mask */
  794. FALSE), /* pcrel_offset */
  795. /* A MIPS16 reference to the global offset table. */
  796. HOWTO (R_MIPS16_GOT16, /* type */
  797. 0, /* rightshift */
  798. 2, /* size (0 = byte, 1 = short, 2 = long) */
  799. 16, /* bitsize */
  800. FALSE, /* pc_relative */
  801. 0, /* bitpos */
  802. complain_overflow_dont, /* complain_on_overflow */
  803. _bfd_mips_elf_got16_reloc, /* special_function */
  804. "R_MIPS16_GOT16", /* name */
  805. TRUE, /* partial_inplace */
  806. 0x0000ffff, /* src_mask */
  807. 0x0000ffff, /* dst_mask */
  808. FALSE), /* pcrel_offset */
  809. /* A MIPS16 call through the global offset table. */
  810. HOWTO (R_MIPS16_CALL16, /* type */
  811. 0, /* rightshift */
  812. 2, /* size (0 = byte, 1 = short, 2 = long) */
  813. 16, /* bitsize */
  814. FALSE, /* pc_relative */
  815. 0, /* bitpos */
  816. complain_overflow_dont, /* complain_on_overflow */
  817. _bfd_mips_elf_generic_reloc, /* special_function */
  818. "R_MIPS16_CALL16", /* name */
  819. TRUE, /* partial_inplace */
  820. 0x0000ffff, /* src_mask */
  821. 0x0000ffff, /* dst_mask */
  822. FALSE), /* pcrel_offset */
  823. /* MIPS16 high 16 bits of symbol value. */
  824. HOWTO (R_MIPS16_HI16, /* type */
  825. 16, /* rightshift */
  826. 2, /* size (0 = byte, 1 = short, 2 = long) */
  827. 16, /* bitsize */
  828. FALSE, /* pc_relative */
  829. 0, /* bitpos */
  830. complain_overflow_dont, /* complain_on_overflow */
  831. _bfd_mips_elf_hi16_reloc, /* special_function */
  832. "R_MIPS16_HI16", /* name */
  833. TRUE, /* partial_inplace */
  834. 0x0000ffff, /* src_mask */
  835. 0x0000ffff, /* dst_mask */
  836. FALSE), /* pcrel_offset */
  837. /* MIPS16 low 16 bits of symbol value. */
  838. HOWTO (R_MIPS16_LO16, /* type */
  839. 0, /* rightshift */
  840. 2, /* size (0 = byte, 1 = short, 2 = long) */
  841. 16, /* bitsize */
  842. FALSE, /* pc_relative */
  843. 0, /* bitpos */
  844. complain_overflow_dont, /* complain_on_overflow */
  845. _bfd_mips_elf_lo16_reloc, /* special_function */
  846. "R_MIPS16_LO16", /* name */
  847. TRUE, /* partial_inplace */
  848. 0x0000ffff, /* src_mask */
  849. 0x0000ffff, /* dst_mask */
  850. FALSE), /* pcrel_offset */
  851. /* MIPS16 TLS general dynamic variable reference. */
  852. HOWTO (R_MIPS16_TLS_GD, /* type */
  853. 0, /* rightshift */
  854. 2, /* size (0 = byte, 1 = short, 2 = long) */
  855. 16, /* bitsize */
  856. FALSE, /* pc_relative */
  857. 0, /* bitpos */
  858. complain_overflow_signed, /* complain_on_overflow */
  859. _bfd_mips_elf_generic_reloc, /* special_function */
  860. "R_MIPS16_TLS_GD", /* name */
  861. TRUE, /* partial_inplace */
  862. 0x0000ffff, /* src_mask */
  863. 0x0000ffff, /* dst_mask */
  864. FALSE), /* pcrel_offset */
  865. /* MIPS16 TLS local dynamic variable reference. */
  866. HOWTO (R_MIPS16_TLS_LDM, /* type */
  867. 0, /* rightshift */
  868. 2, /* size (0 = byte, 1 = short, 2 = long) */
  869. 16, /* bitsize */
  870. FALSE, /* pc_relative */
  871. 0, /* bitpos */
  872. complain_overflow_signed, /* complain_on_overflow */
  873. _bfd_mips_elf_generic_reloc, /* special_function */
  874. "R_MIPS16_TLS_LDM", /* name */
  875. TRUE, /* partial_inplace */
  876. 0x0000ffff, /* src_mask */
  877. 0x0000ffff, /* dst_mask */
  878. FALSE), /* pcrel_offset */
  879. /* MIPS16 TLS local dynamic offset. */
  880. HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */
  881. 0, /* rightshift */
  882. 2, /* size (0 = byte, 1 = short, 2 = long) */
  883. 16, /* bitsize */
  884. FALSE, /* pc_relative */
  885. 0, /* bitpos */
  886. complain_overflow_signed, /* complain_on_overflow */
  887. _bfd_mips_elf_generic_reloc, /* special_function */
  888. "R_MIPS16_TLS_DTPREL_HI16", /* name */
  889. TRUE, /* partial_inplace */
  890. 0x0000ffff, /* src_mask */
  891. 0x0000ffff, /* dst_mask */
  892. FALSE), /* pcrel_offset */
  893. /* MIPS16 TLS local dynamic offset. */
  894. HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */
  895. 0, /* rightshift */
  896. 2, /* size (0 = byte, 1 = short, 2 = long) */
  897. 16, /* bitsize */
  898. FALSE, /* pc_relative */
  899. 0, /* bitpos */
  900. complain_overflow_signed, /* complain_on_overflow */
  901. _bfd_mips_elf_generic_reloc, /* special_function */
  902. "R_MIPS16_TLS_DTPREL_LO16", /* name */
  903. TRUE, /* partial_inplace */
  904. 0x0000ffff, /* src_mask */
  905. 0x0000ffff, /* dst_mask */
  906. FALSE), /* pcrel_offset */
  907. /* MIPS16 TLS thread pointer offset. */
  908. HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */
  909. 0, /* rightshift */
  910. 2, /* size (0 = byte, 1 = short, 2 = long) */
  911. 16, /* bitsize */
  912. FALSE, /* pc_relative */
  913. 0, /* bitpos */
  914. complain_overflow_signed, /* complain_on_overflow */
  915. _bfd_mips_elf_generic_reloc, /* special_function */
  916. "R_MIPS16_TLS_GOTTPREL", /* name */
  917. TRUE, /* partial_inplace */
  918. 0x0000ffff, /* src_mask */
  919. 0x0000ffff, /* dst_mask */
  920. FALSE), /* pcrel_offset */
  921. /* MIPS16 TLS thread pointer offset. */
  922. HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */
  923. 0, /* rightshift */
  924. 2, /* size (0 = byte, 1 = short, 2 = long) */
  925. 16, /* bitsize */
  926. FALSE, /* pc_relative */
  927. 0, /* bitpos */
  928. complain_overflow_signed, /* complain_on_overflow */
  929. _bfd_mips_elf_generic_reloc, /* special_function */
  930. "R_MIPS16_TLS_TPREL_HI16", /* name */
  931. TRUE, /* partial_inplace */
  932. 0x0000ffff, /* src_mask */
  933. 0x0000ffff, /* dst_mask */
  934. FALSE), /* pcrel_offset */
  935. /* MIPS16 TLS thread pointer offset. */
  936. HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */
  937. 0, /* rightshift */
  938. 2, /* size (0 = byte, 1 = short, 2 = long) */
  939. 16, /* bitsize */
  940. FALSE, /* pc_relative */
  941. 0, /* bitpos */
  942. complain_overflow_signed, /* complain_on_overflow */
  943. _bfd_mips_elf_generic_reloc, /* special_function */
  944. "R_MIPS16_TLS_TPREL_LO16", /* name */
  945. TRUE, /* partial_inplace */
  946. 0x0000ffff, /* src_mask */
  947. 0x0000ffff, /* dst_mask */
  948. FALSE), /* pcrel_offset */
  949. };
  950. static reloc_howto_type elf_micromips_howto_table_rel[] =
  951. {
  952. EMPTY_HOWTO (130),
  953. EMPTY_HOWTO (131),
  954. EMPTY_HOWTO (132),
  955. /* 26 bit jump address. */
  956. HOWTO (R_MICROMIPS_26_S1, /* type */
  957. 1, /* rightshift */
  958. 2, /* size (0 = byte, 1 = short, 2 = long) */
  959. 26, /* bitsize */
  960. FALSE, /* pc_relative */
  961. 0, /* bitpos */
  962. complain_overflow_dont, /* complain_on_overflow */
  963. /* This needs complex overflow
  964. detection, because the upper four
  965. bits must match the PC. */
  966. _bfd_mips_elf_generic_reloc, /* special_function */
  967. "R_MICROMIPS_26_S1", /* name */
  968. TRUE, /* partial_inplace */
  969. 0x3ffffff, /* src_mask */
  970. 0x3ffffff, /* dst_mask */
  971. FALSE), /* pcrel_offset */
  972. /* High 16 bits of symbol value. */
  973. HOWTO (R_MICROMIPS_HI16, /* type */
  974. 16, /* rightshift */
  975. 2, /* size (0 = byte, 1 = short, 2 = long) */
  976. 16, /* bitsize */
  977. FALSE, /* pc_relative */
  978. 0, /* bitpos */
  979. complain_overflow_dont, /* complain_on_overflow */
  980. _bfd_mips_elf_hi16_reloc, /* special_function */
  981. "R_MICROMIPS_HI16", /* name */
  982. TRUE, /* partial_inplace */
  983. 0x0000ffff, /* src_mask */
  984. 0x0000ffff, /* dst_mask */
  985. FALSE), /* pcrel_offset */
  986. /* Low 16 bits of symbol value. */
  987. HOWTO (R_MICROMIPS_LO16, /* type */
  988. 0, /* rightshift */
  989. 2, /* size (0 = byte, 1 = short, 2 = long) */
  990. 16, /* bitsize */
  991. FALSE, /* pc_relative */
  992. 0, /* bitpos */
  993. complain_overflow_dont, /* complain_on_overflow */
  994. _bfd_mips_elf_lo16_reloc, /* special_function */
  995. "R_MICROMIPS_LO16", /* name */
  996. TRUE, /* partial_inplace */
  997. 0x0000ffff, /* src_mask */
  998. 0x0000ffff, /* dst_mask */
  999. FALSE), /* pcrel_offset */
  1000. /* GP relative reference. */
  1001. HOWTO (R_MICROMIPS_GPREL16, /* type */
  1002. 0, /* rightshift */
  1003. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1004. 16, /* bitsize */
  1005. FALSE, /* pc_relative */
  1006. 0, /* bitpos */
  1007. complain_overflow_signed, /* complain_on_overflow */
  1008. _bfd_mips_elf32_gprel16_reloc, /* special_function */
  1009. "R_MICROMIPS_GPREL16", /* name */
  1010. TRUE, /* partial_inplace */
  1011. 0x0000ffff, /* src_mask */
  1012. 0x0000ffff, /* dst_mask */
  1013. FALSE), /* pcrel_offset */
  1014. /* Reference to literal section. */
  1015. HOWTO (R_MICROMIPS_LITERAL, /* type */
  1016. 0, /* rightshift */
  1017. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1018. 16, /* bitsize */
  1019. FALSE, /* pc_relative */
  1020. 0, /* bitpos */
  1021. complain_overflow_signed, /* complain_on_overflow */
  1022. _bfd_mips_elf32_gprel16_reloc, /* special_function */
  1023. "R_MICROMIPS_LITERAL", /* name */
  1024. TRUE, /* partial_inplace */
  1025. 0x0000ffff, /* src_mask */
  1026. 0x0000ffff, /* dst_mask */
  1027. FALSE), /* pcrel_offset */
  1028. /* Reference to global offset table. */
  1029. HOWTO (R_MICROMIPS_GOT16, /* type */
  1030. 0, /* rightshift */
  1031. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1032. 16, /* bitsize */
  1033. FALSE, /* pc_relative */
  1034. 0, /* bitpos */
  1035. complain_overflow_signed, /* complain_on_overflow */
  1036. _bfd_mips_elf_got16_reloc, /* special_function */
  1037. "R_MICROMIPS_GOT16", /* name */
  1038. TRUE, /* partial_inplace */
  1039. 0x0000ffff, /* src_mask */
  1040. 0x0000ffff, /* dst_mask */
  1041. FALSE), /* pcrel_offset */
  1042. /* This is for microMIPS branches. */
  1043. HOWTO (R_MICROMIPS_PC7_S1, /* type */
  1044. 1, /* rightshift */
  1045. 1, /* size (0 = byte, 1 = short, 2 = long) */
  1046. 7, /* bitsize */
  1047. TRUE, /* pc_relative */
  1048. 0, /* bitpos */
  1049. complain_overflow_signed, /* complain_on_overflow */
  1050. _bfd_mips_elf_generic_reloc, /* special_function */
  1051. "R_MICROMIPS_PC7_S1", /* name */
  1052. TRUE, /* partial_inplace */
  1053. 0x0000007f, /* src_mask */
  1054. 0x0000007f, /* dst_mask */
  1055. TRUE), /* pcrel_offset */
  1056. HOWTO (R_MICROMIPS_PC10_S1, /* type */
  1057. 1, /* rightshift */
  1058. 1, /* size (0 = byte, 1 = short, 2 = long) */
  1059. 10, /* bitsize */
  1060. TRUE, /* pc_relative */
  1061. 0, /* bitpos */
  1062. complain_overflow_signed, /* complain_on_overflow */
  1063. _bfd_mips_elf_generic_reloc, /* special_function */
  1064. "R_MICROMIPS_PC10_S1", /* name */
  1065. TRUE, /* partial_inplace */
  1066. 0x000003ff, /* src_mask */
  1067. 0x000003ff, /* dst_mask */
  1068. TRUE), /* pcrel_offset */
  1069. HOWTO (R_MICROMIPS_PC16_S1, /* type */
  1070. 1, /* rightshift */
  1071. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1072. 16, /* bitsize */
  1073. TRUE, /* pc_relative */
  1074. 0, /* bitpos */
  1075. complain_overflow_signed, /* complain_on_overflow */
  1076. _bfd_mips_elf_generic_reloc, /* special_function */
  1077. "R_MICROMIPS_PC16_S1", /* name */
  1078. TRUE, /* partial_inplace */
  1079. 0x0000ffff, /* src_mask */
  1080. 0x0000ffff, /* dst_mask */
  1081. TRUE), /* pcrel_offset */
  1082. /* 16 bit call through global offset table. */
  1083. HOWTO (R_MICROMIPS_CALL16, /* type */
  1084. 0, /* rightshift */
  1085. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1086. 16, /* bitsize */
  1087. FALSE, /* pc_relative */
  1088. 0, /* bitpos */
  1089. complain_overflow_signed, /* complain_on_overflow */
  1090. _bfd_mips_elf_generic_reloc, /* special_function */
  1091. "R_MICROMIPS_CALL16", /* name */
  1092. TRUE, /* partial_inplace */
  1093. 0x0000ffff, /* src_mask */
  1094. 0x0000ffff, /* dst_mask */
  1095. FALSE), /* pcrel_offset */
  1096. EMPTY_HOWTO (143),
  1097. EMPTY_HOWTO (144),
  1098. /* Displacement in the global offset table. */
  1099. HOWTO (R_MICROMIPS_GOT_DISP, /* type */
  1100. 0, /* rightshift */
  1101. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1102. 16, /* bitsize */
  1103. FALSE, /* pc_relative */
  1104. 0, /* bitpos */
  1105. complain_overflow_signed, /* complain_on_overflow */
  1106. _bfd_mips_elf_generic_reloc, /* special_function */
  1107. "R_MICROMIPS_GOT_DISP",/* name */
  1108. TRUE, /* partial_inplace */
  1109. 0x0000ffff, /* src_mask */
  1110. 0x0000ffff, /* dst_mask */
  1111. FALSE), /* pcrel_offset */
  1112. /* Displacement to page pointer in the global offset table. */
  1113. HOWTO (R_MICROMIPS_GOT_PAGE, /* type */
  1114. 0, /* rightshift */
  1115. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1116. 16, /* bitsize */
  1117. FALSE, /* pc_relative */
  1118. 0, /* bitpos */
  1119. complain_overflow_signed, /* complain_on_overflow */
  1120. _bfd_mips_elf_generic_reloc, /* special_function */
  1121. "R_MICROMIPS_GOT_PAGE",/* name */
  1122. TRUE, /* partial_inplace */
  1123. 0x0000ffff, /* src_mask */
  1124. 0x0000ffff, /* dst_mask */
  1125. FALSE), /* pcrel_offset */
  1126. /* Offset from page pointer in the global offset table. */
  1127. HOWTO (R_MICROMIPS_GOT_OFST, /* type */
  1128. 0, /* rightshift */
  1129. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1130. 16, /* bitsize */
  1131. FALSE, /* pc_relative */
  1132. 0, /* bitpos */
  1133. complain_overflow_signed, /* complain_on_overflow */
  1134. _bfd_mips_elf_generic_reloc, /* special_function */
  1135. "R_MICROMIPS_GOT_OFST",/* name */
  1136. TRUE, /* partial_inplace */
  1137. 0x0000ffff, /* src_mask */
  1138. 0x0000ffff, /* dst_mask */
  1139. FALSE), /* pcrel_offset */
  1140. /* High 16 bits of displacement in global offset table. */
  1141. HOWTO (R_MICROMIPS_GOT_HI16, /* type */
  1142. 0, /* rightshift */
  1143. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1144. 16, /* bitsize */
  1145. FALSE, /* pc_relative */
  1146. 0, /* bitpos */
  1147. complain_overflow_dont, /* complain_on_overflow */
  1148. _bfd_mips_elf_generic_reloc, /* special_function */
  1149. "R_MICROMIPS_GOT_HI16",/* name */
  1150. TRUE, /* partial_inplace */
  1151. 0x0000ffff, /* src_mask */
  1152. 0x0000ffff, /* dst_mask */
  1153. FALSE), /* pcrel_offset */
  1154. /* Low 16 bits of displacement in global offset table. */
  1155. HOWTO (R_MICROMIPS_GOT_LO16, /* type */
  1156. 0, /* rightshift */
  1157. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1158. 16, /* bitsize */
  1159. FALSE, /* pc_relative */
  1160. 0, /* bitpos */
  1161. complain_overflow_dont, /* complain_on_overflow */
  1162. _bfd_mips_elf_generic_reloc, /* special_function */
  1163. "R_MICROMIPS_GOT_LO16",/* name */
  1164. TRUE, /* partial_inplace */
  1165. 0x0000ffff, /* src_mask */
  1166. 0x0000ffff, /* dst_mask */
  1167. FALSE), /* pcrel_offset */
  1168. /* 64 bit subtraction. Used in the N32 ABI. */
  1169. HOWTO (R_MICROMIPS_SUB, /* type */
  1170. 0, /* rightshift */
  1171. 4, /* size (0 = byte, 1 = short, 2 = long) */
  1172. 64, /* bitsize */
  1173. FALSE, /* pc_relative */
  1174. 0, /* bitpos */
  1175. complain_overflow_dont, /* complain_on_overflow */
  1176. _bfd_mips_elf_generic_reloc, /* special_function */
  1177. "R_MICROMIPS_SUB", /* name */
  1178. TRUE, /* partial_inplace */
  1179. MINUS_ONE, /* src_mask */
  1180. MINUS_ONE, /* dst_mask */
  1181. FALSE), /* pcrel_offset */
  1182. /* Get the higher value of a 64 bit addend. */
  1183. HOWTO (R_MICROMIPS_HIGHER, /* type */
  1184. 0, /* rightshift */
  1185. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1186. 16, /* bitsize */
  1187. FALSE, /* pc_relative */
  1188. 0, /* bitpos */
  1189. complain_overflow_dont, /* complain_on_overflow */
  1190. _bfd_mips_elf_generic_reloc, /* special_function */
  1191. "R_MICROMIPS_HIGHER", /* name */
  1192. TRUE, /* partial_inplace */
  1193. 0x0000ffff, /* src_mask */
  1194. 0x0000ffff, /* dst_mask */
  1195. FALSE), /* pcrel_offset */
  1196. /* Get the highest value of a 64 bit addend. */
  1197. HOWTO (R_MICROMIPS_HIGHEST, /* type */
  1198. 0, /* rightshift */
  1199. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1200. 16, /* bitsize */
  1201. FALSE, /* pc_relative */
  1202. 0, /* bitpos */
  1203. complain_overflow_dont, /* complain_on_overflow */
  1204. _bfd_mips_elf_generic_reloc, /* special_function */
  1205. "R_MICROMIPS_HIGHEST", /* name */
  1206. TRUE, /* partial_inplace */
  1207. 0x0000ffff, /* src_mask */
  1208. 0x0000ffff, /* dst_mask */
  1209. FALSE), /* pcrel_offset */
  1210. /* High 16 bits of displacement in global offset table. */
  1211. HOWTO (R_MICROMIPS_CALL_HI16, /* type */
  1212. 0, /* rightshift */
  1213. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1214. 16, /* bitsize */
  1215. FALSE, /* pc_relative */
  1216. 0, /* bitpos */
  1217. complain_overflow_dont, /* complain_on_overflow */
  1218. _bfd_mips_elf_generic_reloc, /* special_function */
  1219. "R_MICROMIPS_CALL_HI16",/* name */
  1220. TRUE, /* partial_inplace */
  1221. 0x0000ffff, /* src_mask */
  1222. 0x0000ffff, /* dst_mask */
  1223. FALSE), /* pcrel_offset */
  1224. /* Low 16 bits of displacement in global offset table. */
  1225. HOWTO (R_MICROMIPS_CALL_LO16, /* type */
  1226. 0, /* rightshift */
  1227. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1228. 16, /* bitsize */
  1229. FALSE, /* pc_relative */
  1230. 0, /* bitpos */
  1231. complain_overflow_dont, /* complain_on_overflow */
  1232. _bfd_mips_elf_generic_reloc, /* special_function */
  1233. "R_MICROMIPS_CALL_LO16",/* name */
  1234. TRUE, /* partial_inplace */
  1235. 0x0000ffff, /* src_mask */
  1236. 0x0000ffff, /* dst_mask */
  1237. FALSE), /* pcrel_offset */
  1238. /* Section displacement. */
  1239. HOWTO (R_MICROMIPS_SCN_DISP, /* type */
  1240. 0, /* rightshift */
  1241. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1242. 32, /* bitsize */
  1243. FALSE, /* pc_relative */
  1244. 0, /* bitpos */
  1245. complain_overflow_dont, /* complain_on_overflow */
  1246. _bfd_mips_elf_generic_reloc, /* special_function */
  1247. "R_MICROMIPS_SCN_DISP",/* name */
  1248. TRUE, /* partial_inplace */
  1249. 0xffffffff, /* src_mask */
  1250. 0xffffffff, /* dst_mask */
  1251. FALSE), /* pcrel_offset */
  1252. /* Protected jump conversion. This is an optimization hint. No
  1253. relocation is required for correctness. */
  1254. HOWTO (R_MICROMIPS_JALR, /* type */
  1255. 0, /* rightshift */
  1256. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1257. 32, /* bitsize */
  1258. FALSE, /* pc_relative */
  1259. 0, /* bitpos */
  1260. complain_overflow_dont, /* complain_on_overflow */
  1261. _bfd_mips_elf_generic_reloc, /* special_function */
  1262. "R_MICROMIPS_JALR", /* name */
  1263. FALSE, /* partial_inplace */
  1264. 0x00000000, /* src_mask */
  1265. 0x00000000, /* dst_mask */
  1266. FALSE), /* pcrel_offset */
  1267. /* Low 16 bits of symbol value. Note that the high 16 bits of symbol values
  1268. must be zero. This is used for relaxation. */
  1269. HOWTO (R_MICROMIPS_HI0_LO16, /* type */
  1270. 0, /* rightshift */
  1271. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1272. 16, /* bitsize */
  1273. FALSE, /* pc_relative */
  1274. 0, /* bitpos */
  1275. complain_overflow_dont, /* complain_on_overflow */
  1276. _bfd_mips_elf_generic_reloc, /* special_function */
  1277. "R_MICROMIPS_HI0_LO16",/* name */
  1278. TRUE, /* partial_inplace */
  1279. 0x0000ffff, /* src_mask */
  1280. 0x0000ffff, /* dst_mask */
  1281. FALSE), /* pcrel_offset */
  1282. EMPTY_HOWTO (158),
  1283. EMPTY_HOWTO (159),
  1284. EMPTY_HOWTO (160),
  1285. EMPTY_HOWTO (161),
  1286. /* TLS general dynamic variable reference. */
  1287. HOWTO (R_MICROMIPS_TLS_GD, /* type */
  1288. 0, /* rightshift */
  1289. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1290. 16, /* bitsize */
  1291. FALSE, /* pc_relative */
  1292. 0, /* bitpos */
  1293. complain_overflow_signed, /* complain_on_overflow */
  1294. _bfd_mips_elf_generic_reloc, /* special_function */
  1295. "R_MICROMIPS_TLS_GD", /* name */
  1296. TRUE, /* partial_inplace */
  1297. 0x0000ffff, /* src_mask */
  1298. 0x0000ffff, /* dst_mask */
  1299. FALSE), /* pcrel_offset */
  1300. /* TLS local dynamic variable reference. */
  1301. HOWTO (R_MICROMIPS_TLS_LDM, /* type */
  1302. 0, /* rightshift */
  1303. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1304. 16, /* bitsize */
  1305. FALSE, /* pc_relative */
  1306. 0, /* bitpos */
  1307. complain_overflow_signed, /* complain_on_overflow */
  1308. _bfd_mips_elf_generic_reloc, /* special_function */
  1309. "R_MICROMIPS_TLS_LDM", /* name */
  1310. TRUE, /* partial_inplace */
  1311. 0x0000ffff, /* src_mask */
  1312. 0x0000ffff, /* dst_mask */
  1313. FALSE), /* pcrel_offset */
  1314. /* TLS local dynamic offset. */
  1315. HOWTO (R_MICROMIPS_TLS_DTPREL_HI16, /* type */
  1316. 0, /* rightshift */
  1317. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1318. 16, /* bitsize */
  1319. FALSE, /* pc_relative */
  1320. 0, /* bitpos */
  1321. complain_overflow_signed, /* complain_on_overflow */
  1322. _bfd_mips_elf_generic_reloc, /* special_function */
  1323. "R_MICROMIPS_TLS_DTPREL_HI16", /* name */
  1324. TRUE, /* partial_inplace */
  1325. 0x0000ffff, /* src_mask */
  1326. 0x0000ffff, /* dst_mask */
  1327. FALSE), /* pcrel_offset */
  1328. /* TLS local dynamic offset. */
  1329. HOWTO (R_MICROMIPS_TLS_DTPREL_LO16, /* type */
  1330. 0, /* rightshift */
  1331. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1332. 16, /* bitsize */
  1333. FALSE, /* pc_relative */
  1334. 0, /* bitpos */
  1335. complain_overflow_signed, /* complain_on_overflow */
  1336. _bfd_mips_elf_generic_reloc, /* special_function */
  1337. "R_MICROMIPS_TLS_DTPREL_LO16", /* name */
  1338. TRUE, /* partial_inplace */
  1339. 0x0000ffff, /* src_mask */
  1340. 0x0000ffff, /* dst_mask */
  1341. FALSE), /* pcrel_offset */
  1342. /* TLS thread pointer offset. */
  1343. HOWTO (R_MICROMIPS_TLS_GOTTPREL, /* type */
  1344. 0, /* rightshift */
  1345. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1346. 16, /* bitsize */
  1347. FALSE, /* pc_relative */
  1348. 0, /* bitpos */
  1349. complain_overflow_signed, /* complain_on_overflow */
  1350. _bfd_mips_elf_generic_reloc, /* special_function */
  1351. "R_MICROMIPS_TLS_GOTTPREL", /* name */
  1352. TRUE, /* partial_inplace */
  1353. 0x0000ffff, /* src_mask */
  1354. 0x0000ffff, /* dst_mask */
  1355. FALSE), /* pcrel_offset */
  1356. EMPTY_HOWTO (167),
  1357. EMPTY_HOWTO (168),
  1358. /* TLS thread pointer offset. */
  1359. HOWTO (R_MICROMIPS_TLS_TPREL_HI16, /* type */
  1360. 0, /* rightshift */
  1361. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1362. 16, /* bitsize */
  1363. FALSE, /* pc_relative */
  1364. 0, /* bitpos */
  1365. complain_overflow_signed, /* complain_on_overflow */
  1366. _bfd_mips_elf_generic_reloc, /* special_function */
  1367. "R_MICROMIPS_TLS_TPREL_HI16", /* name */
  1368. TRUE, /* partial_inplace */
  1369. 0x0000ffff, /* src_mask */
  1370. 0x0000ffff, /* dst_mask */
  1371. FALSE), /* pcrel_offset */
  1372. /* TLS thread pointer offset. */
  1373. HOWTO (R_MICROMIPS_TLS_TPREL_LO16, /* type */
  1374. 0, /* rightshift */
  1375. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1376. 16, /* bitsize */
  1377. FALSE, /* pc_relative */
  1378. 0, /* bitpos */
  1379. complain_overflow_signed, /* complain_on_overflow */
  1380. _bfd_mips_elf_generic_reloc, /* special_function */
  1381. "R_MICROMIPS_TLS_TPREL_LO16", /* name */
  1382. TRUE, /* partial_inplace */
  1383. 0x0000ffff, /* src_mask */
  1384. 0x0000ffff, /* dst_mask */
  1385. FALSE), /* pcrel_offset */
  1386. EMPTY_HOWTO (171),
  1387. /* GP- and PC-relative relocations. */
  1388. HOWTO (R_MICROMIPS_GPREL7_S2, /* type */
  1389. 2, /* rightshift */
  1390. 1, /* size (0 = byte, 1 = short, 2 = long) */
  1391. 7, /* bitsize */
  1392. FALSE, /* pc_relative */
  1393. 0, /* bitpos */
  1394. complain_overflow_signed, /* complain_on_overflow */
  1395. _bfd_mips_elf32_gprel16_reloc, /* special_function */
  1396. "R_MICROMIPS_GPREL7_S2", /* name */
  1397. TRUE, /* partial_inplace */
  1398. 0x0000007f, /* src_mask */
  1399. 0x0000007f, /* dst_mask */
  1400. FALSE), /* pcrel_offset */
  1401. HOWTO (R_MICROMIPS_PC23_S2, /* type */
  1402. 2, /* rightshift */
  1403. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1404. 23, /* bitsize */
  1405. TRUE, /* pc_relative */
  1406. 0, /* bitpos */
  1407. complain_overflow_signed, /* complain_on_overflow */
  1408. _bfd_mips_elf_generic_reloc, /* special_function */
  1409. "R_MICROMIPS_PC23_S2", /* name */
  1410. TRUE, /* partial_inplace */
  1411. 0x007fffff, /* src_mask */
  1412. 0x007fffff, /* dst_mask */
  1413. TRUE), /* pcrel_offset */
  1414. };
  1415. /* 16 bit offset for pc-relative branches. */
  1416. static reloc_howto_type elf_mips_gnu_rel16_s2 =
  1417. HOWTO (R_MIPS_GNU_REL16_S2, /* type */
  1418. 2, /* rightshift */
  1419. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1420. 16, /* bitsize */
  1421. TRUE, /* pc_relative */
  1422. 0, /* bitpos */
  1423. complain_overflow_signed, /* complain_on_overflow */
  1424. _bfd_mips_elf_generic_reloc, /* special_function */
  1425. "R_MIPS_GNU_REL16_S2", /* name */
  1426. TRUE, /* partial_inplace */
  1427. 0xffff, /* src_mask */
  1428. 0xffff, /* dst_mask */
  1429. TRUE); /* pcrel_offset */
  1430. /* 32 bit pc-relative. This was a GNU extension used by embedded-PIC.
  1431. It was co-opted by mips-linux for exception-handling data. It is no
  1432. longer used, but should continue to be supported by the linker for
  1433. backward compatibility. (GCC stopped using it in May, 2004.) */
  1434. static reloc_howto_type elf_mips_gnu_pcrel32 =
  1435. HOWTO (R_MIPS_PC32, /* type */
  1436. 0, /* rightshift */
  1437. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1438. 32, /* bitsize */
  1439. TRUE, /* pc_relative */
  1440. 0, /* bitpos */
  1441. complain_overflow_signed, /* complain_on_overflow */
  1442. _bfd_mips_elf_generic_reloc, /* special_function */
  1443. "R_MIPS_PC32", /* name */
  1444. TRUE, /* partial_inplace */
  1445. 0xffffffff, /* src_mask */
  1446. 0xffffffff, /* dst_mask */
  1447. TRUE); /* pcrel_offset */
  1448. /* GNU extension to record C++ vtable hierarchy */
  1449. static reloc_howto_type elf_mips_gnu_vtinherit_howto =
  1450. HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
  1451. 0, /* rightshift */
  1452. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1453. 0, /* bitsize */
  1454. FALSE, /* pc_relative */
  1455. 0, /* bitpos */
  1456. complain_overflow_dont, /* complain_on_overflow */
  1457. NULL, /* special_function */
  1458. "R_MIPS_GNU_VTINHERIT", /* name */
  1459. FALSE, /* partial_inplace */
  1460. 0, /* src_mask */
  1461. 0, /* dst_mask */
  1462. FALSE); /* pcrel_offset */
  1463. /* GNU extension to record C++ vtable member usage */
  1464. static reloc_howto_type elf_mips_gnu_vtentry_howto =
  1465. HOWTO (R_MIPS_GNU_VTENTRY, /* type */
  1466. 0, /* rightshift */
  1467. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1468. 0, /* bitsize */
  1469. FALSE, /* pc_relative */
  1470. 0, /* bitpos */
  1471. complain_overflow_dont, /* complain_on_overflow */
  1472. _bfd_elf_rel_vtable_reloc_fn, /* special_function */
  1473. "R_MIPS_GNU_VTENTRY", /* name */
  1474. FALSE, /* partial_inplace */
  1475. 0, /* src_mask */
  1476. 0, /* dst_mask */
  1477. FALSE); /* pcrel_offset */
  1478. /* Originally a VxWorks extension, but now used for other systems too. */
  1479. static reloc_howto_type elf_mips_copy_howto =
  1480. HOWTO (R_MIPS_COPY, /* type */
  1481. 0, /* rightshift */
  1482. 0, /* this one is variable size */
  1483. 0, /* bitsize */
  1484. FALSE, /* pc_relative */
  1485. 0, /* bitpos */
  1486. complain_overflow_bitfield, /* complain_on_overflow */
  1487. _bfd_mips_elf_generic_reloc, /* special_function */
  1488. "R_MIPS_COPY", /* name */
  1489. FALSE, /* partial_inplace */
  1490. 0x0, /* src_mask */
  1491. 0x0, /* dst_mask */
  1492. FALSE); /* pcrel_offset */
  1493. /* Originally a VxWorks extension, but now used for other systems too. */
  1494. static reloc_howto_type elf_mips_jump_slot_howto =
  1495. HOWTO (R_MIPS_JUMP_SLOT, /* type */
  1496. 0, /* rightshift */
  1497. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1498. 32, /* bitsize */
  1499. FALSE, /* pc_relative */
  1500. 0, /* bitpos */
  1501. complain_overflow_bitfield, /* complain_on_overflow */
  1502. _bfd_mips_elf_generic_reloc, /* special_function */
  1503. "R_MIPS_JUMP_SLOT", /* name */
  1504. FALSE, /* partial_inplace */
  1505. 0x0, /* src_mask */
  1506. 0x0, /* dst_mask */
  1507. FALSE); /* pcrel_offset */
  1508. /* Used in EH tables. */
  1509. static reloc_howto_type elf_mips_eh_howto =
  1510. HOWTO (R_MIPS_EH, /* type */
  1511. 0, /* rightshift */
  1512. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1513. 32, /* bitsize */
  1514. FALSE, /* pc_relative */
  1515. 0, /* bitpos */
  1516. complain_overflow_signed, /* complain_on_overflow */
  1517. _bfd_mips_elf_generic_reloc, /* special_function */
  1518. "R_MIPS_EH", /* name */
  1519. TRUE, /* partial_inplace */
  1520. 0xffffffff, /* src_mask */
  1521. 0xffffffff, /* dst_mask */
  1522. FALSE); /* pcrel_offset */
  1523. /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
  1524. dangerous relocation. */
  1525. static bfd_boolean
  1526. mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
  1527. {
  1528. unsigned int count;
  1529. asymbol **sym;
  1530. unsigned int i;
  1531. /* If we've already figured out what GP will be, just return it. */
  1532. *pgp = _bfd_get_gp_value (output_bfd);
  1533. if (*pgp)
  1534. return TRUE;
  1535. count = bfd_get_symcount (output_bfd);
  1536. sym = bfd_get_outsymbols (output_bfd);
  1537. /* The linker script will have created a symbol named `_gp' with the
  1538. appropriate value. */
  1539. if (sym == NULL)
  1540. i = count;
  1541. else
  1542. {
  1543. for (i = 0; i < count; i++, sym++)
  1544. {
  1545. register const char *name;
  1546. name = bfd_asymbol_name (*sym);
  1547. if (*name == '_' && strcmp (name, "_gp") == 0)
  1548. {
  1549. *pgp = bfd_asymbol_value (*sym);
  1550. _bfd_set_gp_value (output_bfd, *pgp);
  1551. break;
  1552. }
  1553. }
  1554. }
  1555. if (i >= count)
  1556. {
  1557. /* Only get the error once. */
  1558. *pgp = 4;
  1559. _bfd_set_gp_value (output_bfd, *pgp);
  1560. return FALSE;
  1561. }
  1562. return TRUE;
  1563. }
  1564. /* We have to figure out the gp value, so that we can adjust the
  1565. symbol value correctly. We look up the symbol _gp in the output
  1566. BFD. If we can't find it, we're stuck. We cache it in the ELF
  1567. target data. We don't need to adjust the symbol value for an
  1568. external symbol if we are producing relocatable output. */
  1569. static bfd_reloc_status_type
  1570. mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
  1571. char **error_message, bfd_vma *pgp)
  1572. {
  1573. if (bfd_is_und_section (symbol->section)
  1574. && ! relocatable)
  1575. {
  1576. *pgp = 0;
  1577. return bfd_reloc_undefined;
  1578. }
  1579. *pgp = _bfd_get_gp_value (output_bfd);
  1580. if (*pgp == 0
  1581. && (! relocatable
  1582. || (symbol->flags & BSF_SECTION_SYM) != 0))
  1583. {
  1584. if (relocatable)
  1585. {
  1586. /* Make up a value. */
  1587. *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
  1588. _bfd_set_gp_value (output_bfd, *pgp);
  1589. }
  1590. else if (!mips_elf_assign_gp (output_bfd, pgp))
  1591. {
  1592. *error_message =
  1593. (char *) _("GP relative relocation when _gp not defined");
  1594. return bfd_reloc_dangerous;
  1595. }
  1596. }
  1597. return bfd_reloc_ok;
  1598. }
  1599. /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
  1600. become the offset from the gp register. This function also handles
  1601. R_MIPS_LITERAL relocations, although those can be handled more
  1602. cleverly because the entries in the .lit8 and .lit4 sections can be
  1603. merged. */
  1604. bfd_reloc_status_type
  1605. _bfd_mips_elf32_gprel16_reloc (bfd *abfd, arelent *reloc_entry,
  1606. asymbol *symbol, void *data,
  1607. asection *input_section, bfd *output_bfd,
  1608. char **error_message)
  1609. {
  1610. bfd_boolean relocatable;
  1611. bfd_reloc_status_type ret;
  1612. bfd_byte *location;
  1613. bfd_vma gp;
  1614. /* R_MIPS_LITERAL/R_MICROMIPS_LITERAL relocations are defined for local
  1615. symbols only. */
  1616. if (literal_reloc_p (reloc_entry->howto->type)
  1617. && output_bfd != NULL
  1618. && (symbol->flags & BSF_SECTION_SYM) == 0
  1619. && (symbol->flags & BSF_LOCAL) != 0)
  1620. {
  1621. *error_message = (char *)
  1622. _("literal relocation occurs for an external symbol");
  1623. return bfd_reloc_outofrange;
  1624. }
  1625. if (output_bfd != NULL)
  1626. relocatable = TRUE;
  1627. else
  1628. {
  1629. relocatable = FALSE;
  1630. output_bfd = symbol->section->output_section->owner;
  1631. }
  1632. ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
  1633. &gp);
  1634. if (ret != bfd_reloc_ok)
  1635. return ret;
  1636. location = (bfd_byte *) data + reloc_entry->address;
  1637. _bfd_mips_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
  1638. location);
  1639. ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
  1640. input_section, relocatable,
  1641. data, gp);
  1642. _bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
  1643. location);
  1644. return ret;
  1645. }
  1646. /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
  1647. become the offset from the gp register. */
  1648. static bfd_reloc_status_type
  1649. mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
  1650. void *data, asection *input_section, bfd *output_bfd,
  1651. char **error_message)
  1652. {
  1653. bfd_boolean relocatable;
  1654. bfd_reloc_status_type ret;
  1655. bfd_vma gp;
  1656. /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
  1657. if (output_bfd != NULL
  1658. && (symbol->flags & BSF_SECTION_SYM) == 0
  1659. && (symbol->flags & BSF_LOCAL) != 0)
  1660. {
  1661. *error_message = (char *)
  1662. _("32bits gp relative relocation occurs for an external symbol");
  1663. return bfd_reloc_outofrange;
  1664. }
  1665. if (output_bfd != NULL)
  1666. relocatable = TRUE;
  1667. else
  1668. {
  1669. relocatable = FALSE;
  1670. output_bfd = symbol->section->output_section->owner;
  1671. }
  1672. ret = mips_elf_final_gp (output_bfd, symbol, relocatable,
  1673. error_message, &gp);
  1674. if (ret != bfd_reloc_ok)
  1675. return ret;
  1676. return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
  1677. relocatable, data, gp);
  1678. }
  1679. static bfd_reloc_status_type
  1680. gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
  1681. asection *input_section, bfd_boolean relocatable,
  1682. void *data, bfd_vma gp)
  1683. {
  1684. bfd_vma relocation;
  1685. bfd_vma val;
  1686. if (bfd_is_com_section (symbol->section))
  1687. relocation = 0;
  1688. else
  1689. relocation = symbol->value;
  1690. relocation += symbol->section->output_section->vma;
  1691. relocation += symbol->section->output_offset;
  1692. if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
  1693. return bfd_reloc_outofrange;
  1694. /* Set val to the offset into the section or symbol. */
  1695. val = reloc_entry->addend;
  1696. if (reloc_entry->howto->partial_inplace)
  1697. val += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
  1698. /* Adjust val for the final section location and GP value. If we
  1699. are producing relocatable output, we don't want to do this for
  1700. an external symbol. */
  1701. if (! relocatable
  1702. || (symbol->flags & BSF_SECTION_SYM) != 0)
  1703. val += relocation - gp;
  1704. if (reloc_entry->howto->partial_inplace)
  1705. bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
  1706. else
  1707. reloc_entry->addend = val;
  1708. if (relocatable)
  1709. reloc_entry->address += input_section->output_offset;
  1710. return bfd_reloc_ok;
  1711. }
  1712. /* Handle a 64 bit reloc in a 32 bit MIPS ELF file. These are
  1713. generated when addresses are 64 bits. The upper 32 bits are a simple
  1714. sign extension. */
  1715. static bfd_reloc_status_type
  1716. mips32_64bit_reloc (bfd *abfd, arelent *reloc_entry,
  1717. asymbol *symbol ATTRIBUTE_UNUSED,
  1718. void *data, asection *input_section,
  1719. bfd *output_bfd, char **error_message)
  1720. {
  1721. bfd_reloc_status_type r;
  1722. arelent reloc32;
  1723. unsigned long val;
  1724. bfd_size_type addr;
  1725. /* Do a normal 32 bit relocation on the lower 32 bits. */
  1726. reloc32 = *reloc_entry;
  1727. if (bfd_big_endian (abfd))
  1728. reloc32.address += 4;
  1729. reloc32.howto = &elf_mips_howto_table_rel[R_MIPS_32];
  1730. r = bfd_perform_relocation (abfd, &reloc32, data, input_section,
  1731. output_bfd, error_message);
  1732. /* Sign extend into the upper 32 bits. */
  1733. val = bfd_get_32 (abfd, (bfd_byte *) data + reloc32.address);
  1734. if ((val & 0x80000000) != 0)
  1735. val = 0xffffffff;
  1736. else
  1737. val = 0;
  1738. addr = reloc_entry->address;
  1739. if (bfd_little_endian (abfd))
  1740. addr += 4;
  1741. bfd_put_32 (abfd, val, (bfd_byte *) data + addr);
  1742. return r;
  1743. }
  1744. /* Handle a mips16 GP relative reloc. */
  1745. static bfd_reloc_status_type
  1746. mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
  1747. void *data, asection *input_section, bfd *output_bfd,
  1748. char **error_message)
  1749. {
  1750. bfd_boolean relocatable;
  1751. bfd_reloc_status_type ret;
  1752. bfd_byte *location;
  1753. bfd_vma gp;
  1754. /* If we're relocating, and this is an external symbol, we don't want
  1755. to change anything. */
  1756. if (output_bfd != NULL
  1757. && (symbol->flags & BSF_SECTION_SYM) == 0
  1758. && (symbol->flags & BSF_LOCAL) != 0)
  1759. {
  1760. reloc_entry->address += input_section->output_offset;
  1761. return bfd_reloc_ok;
  1762. }
  1763. if (output_bfd != NULL)
  1764. relocatable = TRUE;
  1765. else
  1766. {
  1767. relocatable = FALSE;
  1768. output_bfd = symbol->section->output_section->owner;
  1769. }
  1770. ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
  1771. &gp);
  1772. if (ret != bfd_reloc_ok)
  1773. return ret;
  1774. location = (bfd_byte *) data + reloc_entry->address;
  1775. _bfd_mips_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
  1776. location);
  1777. ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
  1778. input_section, relocatable,
  1779. data, gp);
  1780. _bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
  1781. location);
  1782. return ret;
  1783. }
  1784. /* A mapping from BFD reloc types to MIPS ELF reloc types. */
  1785. struct elf_reloc_map {
  1786. bfd_reloc_code_real_type bfd_val;
  1787. enum elf_mips_reloc_type elf_val;
  1788. };
  1789. static const struct elf_reloc_map mips_reloc_map[] =
  1790. {
  1791. { BFD_RELOC_NONE, R_MIPS_NONE },
  1792. { BFD_RELOC_16, R_MIPS_16 },
  1793. { BFD_RELOC_32, R_MIPS_32 },
  1794. /* There is no BFD reloc for R_MIPS_REL32. */
  1795. { BFD_RELOC_64, R_MIPS_64 },
  1796. { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
  1797. { BFD_RELOC_HI16_S, R_MIPS_HI16 },
  1798. { BFD_RELOC_LO16, R_MIPS_LO16 },
  1799. { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
  1800. { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
  1801. { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
  1802. { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
  1803. { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
  1804. { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
  1805. { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
  1806. { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
  1807. { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
  1808. { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
  1809. { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
  1810. { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
  1811. { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
  1812. { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
  1813. { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
  1814. { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
  1815. { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
  1816. { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
  1817. { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
  1818. { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
  1819. { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
  1820. { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
  1821. { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
  1822. { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
  1823. { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
  1824. { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
  1825. { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
  1826. { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 },
  1827. { BFD_RELOC_MIPS_21_PCREL_S2, R_MIPS_PC21_S2 },
  1828. { BFD_RELOC_MIPS_26_PCREL_S2, R_MIPS_PC26_S2 },
  1829. { BFD_RELOC_MIPS_18_PCREL_S3, R_MIPS_PC18_S3 },
  1830. { BFD_RELOC_MIPS_19_PCREL_S2, R_MIPS_PC19_S2 },
  1831. { BFD_RELOC_HI16_S_PCREL, R_MIPS_PCHI16 },
  1832. { BFD_RELOC_LO16_PCREL, R_MIPS_PCLO16 }
  1833. };
  1834. static const struct elf_reloc_map mips16_reloc_map[] =
  1835. {
  1836. { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
  1837. { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
  1838. { BFD_RELOC_MIPS16_GOT16, R_MIPS16_GOT16 - R_MIPS16_min },
  1839. { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
  1840. { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
  1841. { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
  1842. { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min },
  1843. { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min },
  1844. { BFD_RELOC_MIPS16_TLS_DTPREL_HI16,
  1845. R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min },
  1846. { BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
  1847. R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min },
  1848. { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min },
  1849. { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min },
  1850. { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min }
  1851. };
  1852. static const struct elf_reloc_map micromips_reloc_map[] =
  1853. {
  1854. { BFD_RELOC_MICROMIPS_JMP, R_MICROMIPS_26_S1 - R_MICROMIPS_min },
  1855. { BFD_RELOC_MICROMIPS_HI16_S, R_MICROMIPS_HI16 - R_MICROMIPS_min },
  1856. { BFD_RELOC_MICROMIPS_LO16, R_MICROMIPS_LO16 - R_MICROMIPS_min },
  1857. { BFD_RELOC_MICROMIPS_GPREL16, R_MICROMIPS_GPREL16 - R_MICROMIPS_min },
  1858. { BFD_RELOC_MICROMIPS_LITERAL, R_MICROMIPS_LITERAL - R_MICROMIPS_min },
  1859. { BFD_RELOC_MICROMIPS_GOT16, R_MICROMIPS_GOT16 - R_MICROMIPS_min },
  1860. { BFD_RELOC_MICROMIPS_7_PCREL_S1, R_MICROMIPS_PC7_S1 - R_MICROMIPS_min },
  1861. { BFD_RELOC_MICROMIPS_10_PCREL_S1, R_MICROMIPS_PC10_S1 - R_MICROMIPS_min },
  1862. { BFD_RELOC_MICROMIPS_16_PCREL_S1, R_MICROMIPS_PC16_S1 - R_MICROMIPS_min },
  1863. { BFD_RELOC_MICROMIPS_CALL16, R_MICROMIPS_CALL16 - R_MICROMIPS_min },
  1864. { BFD_RELOC_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_DISP - R_MICROMIPS_min },
  1865. { BFD_RELOC_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE - R_MICROMIPS_min },
  1866. { BFD_RELOC_MICROMIPS_GOT_OFST, R_MICROMIPS_GOT_OFST - R_MICROMIPS_min },
  1867. { BFD_RELOC_MICROMIPS_GOT_HI16, R_MICROMIPS_GOT_HI16 - R_MICROMIPS_min },
  1868. { BFD_RELOC_MICROMIPS_GOT_LO16, R_MICROMIPS_GOT_LO16 - R_MICROMIPS_min },
  1869. { BFD_RELOC_MICROMIPS_SUB, R_MICROMIPS_SUB - R_MICROMIPS_min },
  1870. { BFD_RELOC_MICROMIPS_HIGHER, R_MICROMIPS_HIGHER - R_MICROMIPS_min },
  1871. { BFD_RELOC_MICROMIPS_HIGHEST, R_MICROMIPS_HIGHEST - R_MICROMIPS_min },
  1872. { BFD_RELOC_MICROMIPS_CALL_HI16, R_MICROMIPS_CALL_HI16 - R_MICROMIPS_min },
  1873. { BFD_RELOC_MICROMIPS_CALL_LO16, R_MICROMIPS_CALL_LO16 - R_MICROMIPS_min },
  1874. { BFD_RELOC_MICROMIPS_SCN_DISP, R_MICROMIPS_SCN_DISP - R_MICROMIPS_min },
  1875. { BFD_RELOC_MICROMIPS_JALR, R_MICROMIPS_JALR - R_MICROMIPS_min },
  1876. /* There is no BFD reloc for R_MICROMIPS_HI0_LO16. */
  1877. { BFD_RELOC_MICROMIPS_TLS_GD, R_MICROMIPS_TLS_GD - R_MICROMIPS_min },
  1878. { BFD_RELOC_MICROMIPS_TLS_LDM, R_MICROMIPS_TLS_LDM - R_MICROMIPS_min },
  1879. { BFD_RELOC_MICROMIPS_TLS_DTPREL_HI16,
  1880. R_MICROMIPS_TLS_DTPREL_HI16 - R_MICROMIPS_min },
  1881. { BFD_RELOC_MICROMIPS_TLS_DTPREL_LO16,
  1882. R_MICROMIPS_TLS_DTPREL_LO16 - R_MICROMIPS_min },
  1883. { BFD_RELOC_MICROMIPS_TLS_GOTTPREL,
  1884. R_MICROMIPS_TLS_GOTTPREL - R_MICROMIPS_min },
  1885. { BFD_RELOC_MICROMIPS_TLS_TPREL_HI16,
  1886. R_MICROMIPS_TLS_TPREL_HI16 - R_MICROMIPS_min },
  1887. { BFD_RELOC_MICROMIPS_TLS_TPREL_LO16,
  1888. R_MICROMIPS_TLS_TPREL_LO16 - R_MICROMIPS_min },
  1889. /* There is no BFD reloc for R_MICROMIPS_GPREL7_S2. */
  1890. /* There is no BFD reloc for R_MICROMIPS_PC23_S2. */
  1891. };
  1892. /* Given a BFD reloc type, return a howto structure. */
  1893. static reloc_howto_type *
  1894. bfd_elf32_bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code)
  1895. {
  1896. unsigned int i;
  1897. reloc_howto_type *howto_table = elf_mips_howto_table_rel;
  1898. reloc_howto_type *howto16_table = elf_mips16_howto_table_rel;
  1899. reloc_howto_type *howto_micromips_table = elf_micromips_howto_table_rel;
  1900. for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
  1901. i++)
  1902. {
  1903. if (mips_reloc_map[i].bfd_val == code)
  1904. return &howto_table[(int) mips_reloc_map[i].elf_val];
  1905. }
  1906. for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
  1907. i++)
  1908. {
  1909. if (mips16_reloc_map[i].bfd_val == code)
  1910. return &howto16_table[(int) mips16_reloc_map[i].elf_val];
  1911. }
  1912. for (i = 0; i < sizeof (micromips_reloc_map) / sizeof (struct elf_reloc_map);
  1913. i++)
  1914. {
  1915. if (micromips_reloc_map[i].bfd_val == code)
  1916. return &howto_micromips_table[(int) micromips_reloc_map[i].elf_val];
  1917. }
  1918. switch (code)
  1919. {
  1920. default:
  1921. bfd_set_error (bfd_error_bad_value);
  1922. return NULL;
  1923. case BFD_RELOC_CTOR:
  1924. /* We need to handle BFD_RELOC_CTOR specially.
  1925. Select the right relocation (R_MIPS_32 or R_MIPS_64) based on the
  1926. size of addresses of the ABI. */
  1927. if ((elf_elfheader (abfd)->e_flags & (E_MIPS_ABI_O64
  1928. | E_MIPS_ABI_EABI64)) != 0)
  1929. return &elf_mips_ctor64_howto;
  1930. else
  1931. return &howto_table[(int) R_MIPS_32];
  1932. case BFD_RELOC_VTABLE_INHERIT:
  1933. return &elf_mips_gnu_vtinherit_howto;
  1934. case BFD_RELOC_VTABLE_ENTRY:
  1935. return &elf_mips_gnu_vtentry_howto;
  1936. case BFD_RELOC_32_PCREL:
  1937. return &elf_mips_gnu_pcrel32;
  1938. case BFD_RELOC_MIPS_COPY:
  1939. return &elf_mips_copy_howto;
  1940. case BFD_RELOC_MIPS_JUMP_SLOT:
  1941. return &elf_mips_jump_slot_howto;
  1942. case BFD_RELOC_MIPS_EH:
  1943. return &elf_mips_eh_howto;
  1944. }
  1945. }
  1946. static reloc_howto_type *
  1947. bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
  1948. const char *r_name)
  1949. {
  1950. unsigned int i;
  1951. for (i = 0;
  1952. i < (sizeof (elf_mips_howto_table_rel)
  1953. / sizeof (elf_mips_howto_table_rel[0]));
  1954. i++)
  1955. if (elf_mips_howto_table_rel[i].name != NULL
  1956. && strcasecmp (elf_mips_howto_table_rel[i].name, r_name) == 0)
  1957. return &elf_mips_howto_table_rel[i];
  1958. for (i = 0;
  1959. i < (sizeof (elf_mips16_howto_table_rel)
  1960. / sizeof (elf_mips16_howto_table_rel[0]));
  1961. i++)
  1962. if (elf_mips16_howto_table_rel[i].name != NULL
  1963. && strcasecmp (elf_mips16_howto_table_rel[i].name, r_name) == 0)
  1964. return &elf_mips16_howto_table_rel[i];
  1965. for (i = 0;
  1966. i < (sizeof (elf_micromips_howto_table_rel)
  1967. / sizeof (elf_micromips_howto_table_rel[0]));
  1968. i++)
  1969. if (elf_micromips_howto_table_rel[i].name != NULL
  1970. && strcasecmp (elf_micromips_howto_table_rel[i].name, r_name) == 0)
  1971. return &elf_micromips_howto_table_rel[i];
  1972. if (strcasecmp (elf_mips_gnu_pcrel32.name, r_name) == 0)
  1973. return &elf_mips_gnu_pcrel32;
  1974. if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0)
  1975. return &elf_mips_gnu_rel16_s2;
  1976. if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0)
  1977. return &elf_mips_gnu_vtinherit_howto;
  1978. if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0)
  1979. return &elf_mips_gnu_vtentry_howto;
  1980. if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
  1981. return &elf_mips_copy_howto;
  1982. if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
  1983. return &elf_mips_jump_slot_howto;
  1984. if (strcasecmp (elf_mips_eh_howto.name, r_name) == 0)
  1985. return &elf_mips_eh_howto;
  1986. return NULL;
  1987. }
  1988. /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
  1989. static reloc_howto_type *
  1990. mips_elf32_rtype_to_howto (unsigned int r_type,
  1991. bfd_boolean rela_p ATTRIBUTE_UNUSED)
  1992. {
  1993. switch (r_type)
  1994. {
  1995. case R_MIPS_GNU_VTINHERIT:
  1996. return &elf_mips_gnu_vtinherit_howto;
  1997. case R_MIPS_GNU_VTENTRY:
  1998. return &elf_mips_gnu_vtentry_howto;
  1999. case R_MIPS_GNU_REL16_S2:
  2000. return &elf_mips_gnu_rel16_s2;
  2001. case R_MIPS_PC32:
  2002. return &elf_mips_gnu_pcrel32;
  2003. case R_MIPS_COPY:
  2004. return &elf_mips_copy_howto;
  2005. case R_MIPS_JUMP_SLOT:
  2006. return &elf_mips_jump_slot_howto;
  2007. case R_MIPS_EH:
  2008. return &elf_mips_eh_howto;
  2009. default:
  2010. if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max)
  2011. return &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min];
  2012. if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
  2013. return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
  2014. if (r_type >= (unsigned int) R_MIPS_max)
  2015. {
  2016. (*_bfd_error_handler) (_("Unrecognised MIPS reloc number: %d"), r_type);
  2017. bfd_set_error (bfd_error_bad_value);
  2018. r_type = R_MIPS_NONE;
  2019. }
  2020. return &elf_mips_howto_table_rel[r_type];
  2021. }
  2022. }
  2023. /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
  2024. static void
  2025. mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
  2026. {
  2027. const struct elf_backend_data *bed;
  2028. unsigned int r_type;
  2029. r_type = ELF32_R_TYPE (dst->r_info);
  2030. bed = get_elf_backend_data (abfd);
  2031. cache_ptr->howto = bed->elf_backend_mips_rtype_to_howto (r_type, FALSE);
  2032. /* The addend for a GPREL16 or LITERAL relocation comes from the GP
  2033. value for the object file. We get the addend now, rather than
  2034. when we do the relocation, because the symbol manipulations done
  2035. by the linker may cause us to lose track of the input BFD. */
  2036. if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
  2037. && (gprel16_reloc_p (r_type) || literal_reloc_p (r_type)))
  2038. cache_ptr->addend = elf_gp (abfd);
  2039. }
  2040. /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
  2041. static void
  2042. mips_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
  2043. {
  2044. mips_info_to_howto_rel (abfd, cache_ptr, dst);
  2045. /* If we ever need to do any extra processing with dst->r_addend
  2046. (the field omitted in an Elf_Internal_Rel) we can do it here. */
  2047. }
  2048. /* Determine whether a symbol is global for the purposes of splitting
  2049. the symbol table into global symbols and local symbols. At least
  2050. on Irix 5, this split must be between section symbols and all other
  2051. symbols. On most ELF targets the split is between static symbols
  2052. and externally visible symbols. */
  2053. static bfd_boolean
  2054. mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
  2055. {
  2056. if (SGI_COMPAT (abfd))
  2057. return (sym->flags & BSF_SECTION_SYM) == 0;
  2058. else
  2059. return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
  2060. || bfd_is_und_section (bfd_get_section (sym))
  2061. || bfd_is_com_section (bfd_get_section (sym)));
  2062. }
  2063. /* Set the right machine number for a MIPS ELF file. */
  2064. static bfd_boolean
  2065. mips_elf32_object_p (bfd *abfd)
  2066. {
  2067. unsigned long mach;
  2068. if (ABI_N32_P (abfd))
  2069. return FALSE;
  2070. /* Irix 5 and 6 are broken. Object file symbol tables are not always
  2071. sorted correctly such that local symbols precede global symbols,
  2072. and the sh_info field in the symbol table is not always right. */
  2073. if (SGI_COMPAT (abfd))
  2074. elf_bad_symtab (abfd) = TRUE;
  2075. mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
  2076. bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
  2077. return TRUE;
  2078. }
  2079. /* MIPS ELF local labels start with '$', not 'L'. */
  2080. static bfd_boolean
  2081. mips_elf_is_local_label_name (bfd *abfd, const char *name)
  2082. {
  2083. if (name[0] == '$')
  2084. return TRUE;
  2085. /* On Irix 6, the labels go back to starting with '.', so we accept
  2086. the generic ELF local label syntax as well. */
  2087. return _bfd_elf_is_local_label_name (abfd, name);
  2088. }
  2089. /* Support for core dump NOTE sections. */
  2090. static bfd_boolean
  2091. elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
  2092. {
  2093. int offset;
  2094. unsigned int size;
  2095. switch (note->descsz)
  2096. {
  2097. default:
  2098. return FALSE;
  2099. case 256: /* Linux/MIPS */
  2100. /* pr_cursig */
  2101. elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
  2102. /* pr_pid */
  2103. elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
  2104. /* pr_reg */
  2105. offset = 72;
  2106. size = 180;
  2107. break;
  2108. }
  2109. /* Make a ".reg/999" section. */
  2110. return _bfd_elfcore_make_pseudosection (abfd, ".reg",
  2111. size, note->descpos + offset);
  2112. }
  2113. static bfd_boolean
  2114. elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
  2115. {
  2116. switch (note->descsz)
  2117. {
  2118. default:
  2119. return FALSE;
  2120. case 128: /* Linux/MIPS elf_prpsinfo */
  2121. elf_tdata (abfd)->core->program
  2122. = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
  2123. elf_tdata (abfd)->core->command
  2124. = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
  2125. }
  2126. /* Note that for some reason, a spurious space is tacked
  2127. onto the end of the args in some (at least one anyway)
  2128. implementations, so strip it off if it exists. */
  2129. {
  2130. char *command = elf_tdata (abfd)->core->command;
  2131. int n = strlen (command);
  2132. if (0 < n && command[n - 1] == ' ')
  2133. command[n - 1] = '\0';
  2134. }
  2135. return TRUE;
  2136. }
  2137. /* Depending on the target vector we generate some version of Irix
  2138. executables or "normal" MIPS ELF ABI executables. */
  2139. static irix_compat_t
  2140. elf32_mips_irix_compat (bfd *abfd)
  2141. {
  2142. if ((abfd->xvec == &mips_elf32_be_vec)
  2143. || (abfd->xvec == &mips_elf32_le_vec))
  2144. return ict_irix5;
  2145. else
  2146. return ict_none;
  2147. }
  2148. /* ECOFF swapping routines. These are used when dealing with the
  2149. .mdebug section, which is in the ECOFF debugging format. */
  2150. static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
  2151. /* Symbol table magic number. */
  2152. magicSym,
  2153. /* Alignment of debugging information. E.g., 4. */
  2154. 4,
  2155. /* Sizes of external symbolic information. */
  2156. sizeof (struct hdr_ext),
  2157. sizeof (struct dnr_ext),
  2158. sizeof (struct pdr_ext),
  2159. sizeof (struct sym_ext),
  2160. sizeof (struct opt_ext),
  2161. sizeof (struct fdr_ext),
  2162. sizeof (struct rfd_ext),
  2163. sizeof (struct ext_ext),
  2164. /* Functions to swap in external symbolic data. */
  2165. ecoff_swap_hdr_in,
  2166. ecoff_swap_dnr_in,
  2167. ecoff_swap_pdr_in,
  2168. ecoff_swap_sym_in,
  2169. ecoff_swap_opt_in,
  2170. ecoff_swap_fdr_in,
  2171. ecoff_swap_rfd_in,
  2172. ecoff_swap_ext_in,
  2173. _bfd_ecoff_swap_tir_in,
  2174. _bfd_ecoff_swap_rndx_in,
  2175. /* Functions to swap out external symbolic data. */
  2176. ecoff_swap_hdr_out,
  2177. ecoff_swap_dnr_out,
  2178. ecoff_swap_pdr_out,
  2179. ecoff_swap_sym_out,
  2180. ecoff_swap_opt_out,
  2181. ecoff_swap_fdr_out,
  2182. ecoff_swap_rfd_out,
  2183. ecoff_swap_ext_out,
  2184. _bfd_ecoff_swap_tir_out,
  2185. _bfd_ecoff_swap_rndx_out,
  2186. /* Function to read in symbolic data. */
  2187. _bfd_mips_elf_read_ecoff_info
  2188. };
  2189. #define ELF_ARCH bfd_arch_mips
  2190. #define ELF_TARGET_ID MIPS_ELF_DATA
  2191. #define ELF_MACHINE_CODE EM_MIPS
  2192. #define elf_backend_collect TRUE
  2193. #define elf_backend_type_change_ok TRUE
  2194. #define elf_backend_can_gc_sections TRUE
  2195. #define elf_backend_gc_mark_extra_sections \
  2196. _bfd_mips_elf_gc_mark_extra_sections
  2197. #define elf_info_to_howto mips_info_to_howto_rela
  2198. #define elf_info_to_howto_rel mips_info_to_howto_rel
  2199. #define elf_backend_sym_is_global mips_elf_sym_is_global
  2200. #define elf_backend_object_p mips_elf32_object_p
  2201. #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
  2202. #define elf_backend_section_processing _bfd_mips_elf_section_processing
  2203. #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
  2204. #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
  2205. #define elf_backend_section_from_bfd_section \
  2206. _bfd_mips_elf_section_from_bfd_section
  2207. #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
  2208. #define elf_backend_link_output_symbol_hook \
  2209. _bfd_mips_elf_link_output_symbol_hook
  2210. #define elf_backend_create_dynamic_sections \
  2211. _bfd_mips_elf_create_dynamic_sections
  2212. #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
  2213. #define elf_backend_merge_symbol_attribute \
  2214. _bfd_mips_elf_merge_symbol_attribute
  2215. #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
  2216. #define elf_backend_adjust_dynamic_symbol \
  2217. _bfd_mips_elf_adjust_dynamic_symbol
  2218. #define elf_backend_always_size_sections \
  2219. _bfd_mips_elf_always_size_sections
  2220. #define elf_backend_size_dynamic_sections \
  2221. _bfd_mips_elf_size_dynamic_sections
  2222. #define elf_backend_init_index_section _bfd_elf_init_1_index_section
  2223. #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
  2224. #define elf_backend_finish_dynamic_symbol \
  2225. _bfd_mips_elf_finish_dynamic_symbol
  2226. #define elf_backend_finish_dynamic_sections \
  2227. _bfd_mips_elf_finish_dynamic_sections
  2228. #define elf_backend_final_write_processing \
  2229. _bfd_mips_elf_final_write_processing
  2230. #define elf_backend_additional_program_headers \
  2231. _bfd_mips_elf_additional_program_headers
  2232. #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
  2233. #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
  2234. #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
  2235. #define elf_backend_copy_indirect_symbol \
  2236. _bfd_mips_elf_copy_indirect_symbol
  2237. #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
  2238. #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
  2239. #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
  2240. #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
  2241. #define elf_backend_may_use_rel_p 1
  2242. #define elf_backend_may_use_rela_p 0
  2243. #define elf_backend_default_use_rela_p 0
  2244. #define elf_backend_sign_extend_vma TRUE
  2245. #define elf_backend_plt_readonly 1
  2246. #define elf_backend_discard_info _bfd_mips_elf_discard_info
  2247. #define elf_backend_ignore_discarded_relocs \
  2248. _bfd_mips_elf_ignore_discarded_relocs
  2249. #define elf_backend_write_section _bfd_mips_elf_write_section
  2250. #define elf_backend_mips_irix_compat elf32_mips_irix_compat
  2251. #define elf_backend_mips_rtype_to_howto mips_elf32_rtype_to_howto
  2252. #define elf_backend_sort_relocs_p _bfd_mips_elf_sort_relocs_p
  2253. #define bfd_elf32_bfd_is_local_label_name \
  2254. mips_elf_is_local_label_name
  2255. #define bfd_elf32_bfd_is_target_special_symbol \
  2256. _bfd_mips_elf_is_target_special_symbol
  2257. #define bfd_elf32_get_synthetic_symtab _bfd_mips_elf_get_synthetic_symtab
  2258. #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
  2259. #define bfd_elf32_find_inliner_info _bfd_mips_elf_find_inliner_info
  2260. #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
  2261. #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
  2262. #define bfd_elf32_bfd_get_relocated_section_contents \
  2263. _bfd_elf_mips_get_relocated_section_contents
  2264. #define bfd_elf32_bfd_link_hash_table_create \
  2265. _bfd_mips_elf_link_hash_table_create
  2266. #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
  2267. #define bfd_elf32_bfd_merge_private_bfd_data \
  2268. _bfd_mips_elf_merge_private_bfd_data
  2269. #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
  2270. #define bfd_elf32_bfd_print_private_bfd_data \
  2271. _bfd_mips_elf_print_private_bfd_data
  2272. #define bfd_elf32_bfd_relax_section _bfd_mips_elf_relax_section
  2273. #define bfd_elf32_mkobject _bfd_mips_elf_mkobject
  2274. /* Support for SGI-ish mips targets. */
  2275. #define TARGET_LITTLE_SYM mips_elf32_le_vec
  2276. #define TARGET_LITTLE_NAME "elf32-littlemips"
  2277. #define TARGET_BIG_SYM mips_elf32_be_vec
  2278. #define TARGET_BIG_NAME "elf32-bigmips"
  2279. /* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses
  2280. a value of 0x1000, and we are compatible. */
  2281. #define ELF_MAXPAGESIZE 0x1000
  2282. #define ELF_COMMONPAGESIZE 0x1000
  2283. #include "elf32-target.h"
  2284. /* Support for traditional mips targets. */
  2285. #undef TARGET_LITTLE_SYM
  2286. #undef TARGET_LITTLE_NAME
  2287. #undef TARGET_BIG_SYM
  2288. #undef TARGET_BIG_NAME
  2289. #undef ELF_MAXPAGESIZE
  2290. #undef ELF_COMMONPAGESIZE
  2291. #define TARGET_LITTLE_SYM mips_elf32_trad_le_vec
  2292. #define TARGET_LITTLE_NAME "elf32-tradlittlemips"
  2293. #define TARGET_BIG_SYM mips_elf32_trad_be_vec
  2294. #define TARGET_BIG_NAME "elf32-tradbigmips"
  2295. /* The MIPS ABI says at Page 5-1:
  2296. Virtual addresses and file offsets for MIPS segments are congruent
  2297. modulo 64 KByte (0x10000) or larger powers of 2. Because 64 KBytes
  2298. is the maximum page size, the files are suitable for paging
  2299. regardless of physical page size. */
  2300. #define ELF_MAXPAGESIZE 0x10000
  2301. #define ELF_COMMONPAGESIZE 0x1000
  2302. #define elf32_bed elf32_tradbed
  2303. /* Include the target file again for this target. */
  2304. #include "elf32-target.h"
  2305. /* FreeBSD support. */
  2306. #undef TARGET_LITTLE_SYM
  2307. #undef TARGET_LITTLE_NAME
  2308. #undef TARGET_BIG_SYM
  2309. #undef TARGET_BIG_NAME
  2310. #define TARGET_LITTLE_SYM mips_elf32_tradfbsd_le_vec
  2311. #define TARGET_LITTLE_NAME "elf32-tradlittlemips-freebsd"
  2312. #define TARGET_BIG_SYM mips_elf32_tradfbsd_be_vec
  2313. #define TARGET_BIG_NAME "elf32-tradbigmips-freebsd"
  2314. #undef ELF_OSABI
  2315. #define ELF_OSABI ELFOSABI_FREEBSD
  2316. #undef elf32_bed
  2317. #define elf32_bed elf32_fbsd_tradbed
  2318. #include "elf32-target.h"
  2319. /* Implement elf_backend_final_write_processing for VxWorks. */
  2320. static void
  2321. mips_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
  2322. {
  2323. _bfd_mips_elf_final_write_processing (abfd, linker);
  2324. elf_vxworks_final_write_processing (abfd, linker);
  2325. }
  2326. #undef TARGET_LITTLE_SYM
  2327. #undef TARGET_LITTLE_NAME
  2328. #undef TARGET_BIG_SYM
  2329. #undef TARGET_BIG_NAME
  2330. #undef ELF_MAXPAGESIZE
  2331. #undef ELF_COMMONPAGESIZE
  2332. #define TARGET_LITTLE_SYM mips_elf32_vxworks_le_vec
  2333. #define TARGET_LITTLE_NAME "elf32-littlemips-vxworks"
  2334. #define TARGET_BIG_SYM mips_elf32_vxworks_be_vec
  2335. #define TARGET_BIG_NAME "elf32-bigmips-vxworks"
  2336. #undef ELF_OSABI
  2337. #undef elf32_bed
  2338. #define elf32_bed elf32_mips_vxworks_bed
  2339. #define ELF_MAXPAGESIZE 0x1000
  2340. #define ELF_COMMONPAGESIZE 0x1000
  2341. #undef elf_backend_want_got_plt
  2342. #define elf_backend_want_got_plt 1
  2343. #undef elf_backend_want_plt_sym
  2344. #define elf_backend_want_plt_sym 1
  2345. #undef elf_backend_may_use_rel_p
  2346. #define elf_backend_may_use_rel_p 0
  2347. #undef elf_backend_may_use_rela_p
  2348. #define elf_backend_may_use_rela_p 1
  2349. #undef elf_backend_default_use_rela_p
  2350. #define elf_backend_default_use_rela_p 1
  2351. #undef elf_backend_got_header_size
  2352. #define elf_backend_got_header_size (4 * 3)
  2353. #undef elf_backend_finish_dynamic_symbol
  2354. #define elf_backend_finish_dynamic_symbol \
  2355. _bfd_mips_vxworks_finish_dynamic_symbol
  2356. #undef bfd_elf32_bfd_link_hash_table_create
  2357. #define bfd_elf32_bfd_link_hash_table_create \
  2358. _bfd_mips_vxworks_link_hash_table_create
  2359. #undef elf_backend_add_symbol_hook
  2360. #define elf_backend_add_symbol_hook \
  2361. elf_vxworks_add_symbol_hook
  2362. #undef elf_backend_link_output_symbol_hook
  2363. #define elf_backend_link_output_symbol_hook \
  2364. elf_vxworks_link_output_symbol_hook
  2365. #undef elf_backend_emit_relocs
  2366. #define elf_backend_emit_relocs \
  2367. elf_vxworks_emit_relocs
  2368. #undef elf_backend_final_write_processing
  2369. #define elf_backend_final_write_processing \
  2370. mips_vxworks_final_write_processing
  2371. #undef elf_backend_additional_program_headers
  2372. #undef elf_backend_modify_segment_map
  2373. #undef elf_backend_symbol_processing
  2374. /* NOTE: elf_backend_rela_normal is not defined for MIPS. */
  2375. #undef bfd_elf32_get_synthetic_symtab
  2376. #include "elf32-target.h"