elf32-mips.c 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729
  1. /* MIPS-specific support for 32-bit ELF
  2. Copyright (C) 1993-2022 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 *, bool, 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 bool mips_info_to_howto_rel
  51. (bfd *, arelent *, Elf_Internal_Rela *);
  52. static bool mips_info_to_howto_rela
  53. (bfd *, arelent *, Elf_Internal_Rela *);
  54. static bool mips_elf_sym_is_global
  55. (bfd *, asymbol *);
  56. static bool mips_elf32_elfsym_local_is_section
  57. (bfd *);
  58. static bool mips_elf32_object_p
  59. (bfd *);
  60. static bool 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 *, bool, char **, bfd_vma *);
  66. static bool mips_elf_assign_gp
  67. (bfd *, bfd_vma *);
  68. static bool elf32_mips_grok_prstatus
  69. (bfd *, Elf_Internal_Note *);
  70. static bool 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. /* MIPS16 16-bit PC-relative branch offset. */
  950. HOWTO (R_MIPS16_PC16_S1, /* type */
  951. 1, /* rightshift */
  952. 2, /* size (0 = byte, 1 = short, 2 = long) */
  953. 16, /* bitsize */
  954. true, /* pc_relative */
  955. 0, /* bitpos */
  956. complain_overflow_signed, /* complain_on_overflow */
  957. _bfd_mips_elf_generic_reloc, /* special_function */
  958. "R_MIPS16_PC16_S1", /* name */
  959. true, /* partial_inplace */
  960. 0x0000ffff, /* src_mask */
  961. 0x0000ffff, /* dst_mask */
  962. true), /* pcrel_offset */
  963. };
  964. static reloc_howto_type elf_micromips_howto_table_rel[] =
  965. {
  966. EMPTY_HOWTO (130),
  967. EMPTY_HOWTO (131),
  968. EMPTY_HOWTO (132),
  969. /* 26 bit jump address. */
  970. HOWTO (R_MICROMIPS_26_S1, /* type */
  971. 1, /* rightshift */
  972. 2, /* size (0 = byte, 1 = short, 2 = long) */
  973. 26, /* bitsize */
  974. false, /* pc_relative */
  975. 0, /* bitpos */
  976. complain_overflow_dont, /* complain_on_overflow */
  977. /* This needs complex overflow
  978. detection, because the upper four
  979. bits must match the PC. */
  980. _bfd_mips_elf_generic_reloc, /* special_function */
  981. "R_MICROMIPS_26_S1", /* name */
  982. true, /* partial_inplace */
  983. 0x3ffffff, /* src_mask */
  984. 0x3ffffff, /* dst_mask */
  985. false), /* pcrel_offset */
  986. /* High 16 bits of symbol value. */
  987. HOWTO (R_MICROMIPS_HI16, /* type */
  988. 16, /* 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_hi16_reloc, /* special_function */
  995. "R_MICROMIPS_HI16", /* name */
  996. true, /* partial_inplace */
  997. 0x0000ffff, /* src_mask */
  998. 0x0000ffff, /* dst_mask */
  999. false), /* pcrel_offset */
  1000. /* Low 16 bits of symbol value. */
  1001. HOWTO (R_MICROMIPS_LO16, /* 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_dont, /* complain_on_overflow */
  1008. _bfd_mips_elf_lo16_reloc, /* special_function */
  1009. "R_MICROMIPS_LO16", /* name */
  1010. true, /* partial_inplace */
  1011. 0x0000ffff, /* src_mask */
  1012. 0x0000ffff, /* dst_mask */
  1013. false), /* pcrel_offset */
  1014. /* GP relative reference. */
  1015. HOWTO (R_MICROMIPS_GPREL16, /* 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_GPREL16", /* name */
  1024. true, /* partial_inplace */
  1025. 0x0000ffff, /* src_mask */
  1026. 0x0000ffff, /* dst_mask */
  1027. false), /* pcrel_offset */
  1028. /* Reference to literal section. */
  1029. HOWTO (R_MICROMIPS_LITERAL, /* 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_elf32_gprel16_reloc, /* special_function */
  1037. "R_MICROMIPS_LITERAL", /* name */
  1038. true, /* partial_inplace */
  1039. 0x0000ffff, /* src_mask */
  1040. 0x0000ffff, /* dst_mask */
  1041. false), /* pcrel_offset */
  1042. /* Reference to global offset table. */
  1043. HOWTO (R_MICROMIPS_GOT16, /* type */
  1044. 0, /* rightshift */
  1045. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1046. 16, /* bitsize */
  1047. false, /* pc_relative */
  1048. 0, /* bitpos */
  1049. complain_overflow_signed, /* complain_on_overflow */
  1050. _bfd_mips_elf_got16_reloc, /* special_function */
  1051. "R_MICROMIPS_GOT16", /* name */
  1052. true, /* partial_inplace */
  1053. 0x0000ffff, /* src_mask */
  1054. 0x0000ffff, /* dst_mask */
  1055. false), /* pcrel_offset */
  1056. /* This is for microMIPS branches. */
  1057. HOWTO (R_MICROMIPS_PC7_S1, /* type */
  1058. 1, /* rightshift */
  1059. 1, /* size (0 = byte, 1 = short, 2 = long) */
  1060. 7, /* bitsize */
  1061. true, /* pc_relative */
  1062. 0, /* bitpos */
  1063. complain_overflow_signed, /* complain_on_overflow */
  1064. _bfd_mips_elf_generic_reloc, /* special_function */
  1065. "R_MICROMIPS_PC7_S1", /* name */
  1066. true, /* partial_inplace */
  1067. 0x0000007f, /* src_mask */
  1068. 0x0000007f, /* dst_mask */
  1069. true), /* pcrel_offset */
  1070. HOWTO (R_MICROMIPS_PC10_S1, /* type */
  1071. 1, /* rightshift */
  1072. 1, /* size (0 = byte, 1 = short, 2 = long) */
  1073. 10, /* bitsize */
  1074. true, /* pc_relative */
  1075. 0, /* bitpos */
  1076. complain_overflow_signed, /* complain_on_overflow */
  1077. _bfd_mips_elf_generic_reloc, /* special_function */
  1078. "R_MICROMIPS_PC10_S1", /* name */
  1079. true, /* partial_inplace */
  1080. 0x000003ff, /* src_mask */
  1081. 0x000003ff, /* dst_mask */
  1082. true), /* pcrel_offset */
  1083. HOWTO (R_MICROMIPS_PC16_S1, /* type */
  1084. 1, /* rightshift */
  1085. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1086. 16, /* bitsize */
  1087. true, /* pc_relative */
  1088. 0, /* bitpos */
  1089. complain_overflow_signed, /* complain_on_overflow */
  1090. _bfd_mips_elf_generic_reloc, /* special_function */
  1091. "R_MICROMIPS_PC16_S1", /* name */
  1092. true, /* partial_inplace */
  1093. 0x0000ffff, /* src_mask */
  1094. 0x0000ffff, /* dst_mask */
  1095. true), /* pcrel_offset */
  1096. /* 16 bit call through global offset table. */
  1097. HOWTO (R_MICROMIPS_CALL16, /* type */
  1098. 0, /* rightshift */
  1099. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1100. 16, /* bitsize */
  1101. false, /* pc_relative */
  1102. 0, /* bitpos */
  1103. complain_overflow_signed, /* complain_on_overflow */
  1104. _bfd_mips_elf_generic_reloc, /* special_function */
  1105. "R_MICROMIPS_CALL16", /* name */
  1106. true, /* partial_inplace */
  1107. 0x0000ffff, /* src_mask */
  1108. 0x0000ffff, /* dst_mask */
  1109. false), /* pcrel_offset */
  1110. EMPTY_HOWTO (143),
  1111. EMPTY_HOWTO (144),
  1112. /* Displacement in the global offset table. */
  1113. HOWTO (R_MICROMIPS_GOT_DISP, /* 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_DISP",/* name */
  1122. true, /* partial_inplace */
  1123. 0x0000ffff, /* src_mask */
  1124. 0x0000ffff, /* dst_mask */
  1125. false), /* pcrel_offset */
  1126. /* Displacement to page pointer in the global offset table. */
  1127. HOWTO (R_MICROMIPS_GOT_PAGE, /* 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_PAGE",/* name */
  1136. true, /* partial_inplace */
  1137. 0x0000ffff, /* src_mask */
  1138. 0x0000ffff, /* dst_mask */
  1139. false), /* pcrel_offset */
  1140. /* Offset from page pointer in the global offset table. */
  1141. HOWTO (R_MICROMIPS_GOT_OFST, /* 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_signed, /* complain_on_overflow */
  1148. _bfd_mips_elf_generic_reloc, /* special_function */
  1149. "R_MICROMIPS_GOT_OFST",/* name */
  1150. true, /* partial_inplace */
  1151. 0x0000ffff, /* src_mask */
  1152. 0x0000ffff, /* dst_mask */
  1153. false), /* pcrel_offset */
  1154. /* High 16 bits of displacement in global offset table. */
  1155. HOWTO (R_MICROMIPS_GOT_HI16, /* 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_HI16",/* name */
  1164. true, /* partial_inplace */
  1165. 0x0000ffff, /* src_mask */
  1166. 0x0000ffff, /* dst_mask */
  1167. false), /* pcrel_offset */
  1168. /* Low 16 bits of displacement in global offset table. */
  1169. HOWTO (R_MICROMIPS_GOT_LO16, /* type */
  1170. 0, /* rightshift */
  1171. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1172. 16, /* 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_GOT_LO16",/* name */
  1178. true, /* partial_inplace */
  1179. 0x0000ffff, /* src_mask */
  1180. 0x0000ffff, /* dst_mask */
  1181. false), /* pcrel_offset */
  1182. /* 64 bit subtraction. Used in the N32 ABI. */
  1183. HOWTO (R_MICROMIPS_SUB, /* type */
  1184. 0, /* rightshift */
  1185. 4, /* size (0 = byte, 1 = short, 2 = long) */
  1186. 64, /* 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_SUB", /* name */
  1192. true, /* partial_inplace */
  1193. MINUS_ONE, /* src_mask */
  1194. MINUS_ONE, /* dst_mask */
  1195. false), /* pcrel_offset */
  1196. /* Get the higher value of a 64 bit addend. */
  1197. HOWTO (R_MICROMIPS_HIGHER, /* 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_HIGHER", /* name */
  1206. true, /* partial_inplace */
  1207. 0x0000ffff, /* src_mask */
  1208. 0x0000ffff, /* dst_mask */
  1209. false), /* pcrel_offset */
  1210. /* Get the highest value of a 64 bit addend. */
  1211. HOWTO (R_MICROMIPS_HIGHEST, /* 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_HIGHEST", /* name */
  1220. true, /* partial_inplace */
  1221. 0x0000ffff, /* src_mask */
  1222. 0x0000ffff, /* dst_mask */
  1223. false), /* pcrel_offset */
  1224. /* High 16 bits of displacement in global offset table. */
  1225. HOWTO (R_MICROMIPS_CALL_HI16, /* 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_HI16",/* name */
  1234. true, /* partial_inplace */
  1235. 0x0000ffff, /* src_mask */
  1236. 0x0000ffff, /* dst_mask */
  1237. false), /* pcrel_offset */
  1238. /* Low 16 bits of displacement in global offset table. */
  1239. HOWTO (R_MICROMIPS_CALL_LO16, /* type */
  1240. 0, /* rightshift */
  1241. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1242. 16, /* 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_CALL_LO16",/* name */
  1248. true, /* partial_inplace */
  1249. 0x0000ffff, /* src_mask */
  1250. 0x0000ffff, /* dst_mask */
  1251. false), /* pcrel_offset */
  1252. /* Section displacement. */
  1253. HOWTO (R_MICROMIPS_SCN_DISP, /* type */
  1254. 0, /* rightshift */
  1255. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1256. 32, /* bitsize */
  1257. false, /* pc_relative */
  1258. 0, /* bitpos */
  1259. complain_overflow_dont, /* complain_on_overflow */
  1260. _bfd_mips_elf_generic_reloc, /* special_function */
  1261. "R_MICROMIPS_SCN_DISP",/* name */
  1262. true, /* partial_inplace */
  1263. 0xffffffff, /* src_mask */
  1264. 0xffffffff, /* dst_mask */
  1265. false), /* pcrel_offset */
  1266. /* Protected jump conversion. This is an optimization hint. No
  1267. relocation is required for correctness. */
  1268. HOWTO (R_MICROMIPS_JALR, /* type */
  1269. 0, /* rightshift */
  1270. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1271. 32, /* bitsize */
  1272. false, /* pc_relative */
  1273. 0, /* bitpos */
  1274. complain_overflow_dont, /* complain_on_overflow */
  1275. _bfd_mips_elf_generic_reloc, /* special_function */
  1276. "R_MICROMIPS_JALR", /* name */
  1277. false, /* partial_inplace */
  1278. 0x00000000, /* src_mask */
  1279. 0x00000000, /* dst_mask */
  1280. false), /* pcrel_offset */
  1281. /* Low 16 bits of symbol value. Note that the high 16 bits of symbol values
  1282. must be zero. This is used for relaxation. */
  1283. HOWTO (R_MICROMIPS_HI0_LO16, /* type */
  1284. 0, /* rightshift */
  1285. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1286. 16, /* bitsize */
  1287. false, /* pc_relative */
  1288. 0, /* bitpos */
  1289. complain_overflow_dont, /* complain_on_overflow */
  1290. _bfd_mips_elf_generic_reloc, /* special_function */
  1291. "R_MICROMIPS_HI0_LO16",/* name */
  1292. true, /* partial_inplace */
  1293. 0x0000ffff, /* src_mask */
  1294. 0x0000ffff, /* dst_mask */
  1295. false), /* pcrel_offset */
  1296. EMPTY_HOWTO (158),
  1297. EMPTY_HOWTO (159),
  1298. EMPTY_HOWTO (160),
  1299. EMPTY_HOWTO (161),
  1300. /* TLS general dynamic variable reference. */
  1301. HOWTO (R_MICROMIPS_TLS_GD, /* 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_GD", /* name */
  1310. true, /* partial_inplace */
  1311. 0x0000ffff, /* src_mask */
  1312. 0x0000ffff, /* dst_mask */
  1313. false), /* pcrel_offset */
  1314. /* TLS local dynamic variable reference. */
  1315. HOWTO (R_MICROMIPS_TLS_LDM, /* 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_LDM", /* 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_HI16, /* 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_HI16", /* name */
  1338. true, /* partial_inplace */
  1339. 0x0000ffff, /* src_mask */
  1340. 0x0000ffff, /* dst_mask */
  1341. false), /* pcrel_offset */
  1342. /* TLS local dynamic offset. */
  1343. HOWTO (R_MICROMIPS_TLS_DTPREL_LO16, /* 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_DTPREL_LO16", /* name */
  1352. true, /* partial_inplace */
  1353. 0x0000ffff, /* src_mask */
  1354. 0x0000ffff, /* dst_mask */
  1355. false), /* pcrel_offset */
  1356. /* TLS thread pointer offset. */
  1357. HOWTO (R_MICROMIPS_TLS_GOTTPREL, /* type */
  1358. 0, /* rightshift */
  1359. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1360. 16, /* bitsize */
  1361. false, /* pc_relative */
  1362. 0, /* bitpos */
  1363. complain_overflow_signed, /* complain_on_overflow */
  1364. _bfd_mips_elf_generic_reloc, /* special_function */
  1365. "R_MICROMIPS_TLS_GOTTPREL", /* name */
  1366. true, /* partial_inplace */
  1367. 0x0000ffff, /* src_mask */
  1368. 0x0000ffff, /* dst_mask */
  1369. false), /* pcrel_offset */
  1370. EMPTY_HOWTO (167),
  1371. EMPTY_HOWTO (168),
  1372. /* TLS thread pointer offset. */
  1373. HOWTO (R_MICROMIPS_TLS_TPREL_HI16, /* 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_HI16", /* name */
  1382. true, /* partial_inplace */
  1383. 0x0000ffff, /* src_mask */
  1384. 0x0000ffff, /* dst_mask */
  1385. false), /* pcrel_offset */
  1386. /* TLS thread pointer offset. */
  1387. HOWTO (R_MICROMIPS_TLS_TPREL_LO16, /* type */
  1388. 0, /* rightshift */
  1389. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1390. 16, /* bitsize */
  1391. false, /* pc_relative */
  1392. 0, /* bitpos */
  1393. complain_overflow_signed, /* complain_on_overflow */
  1394. _bfd_mips_elf_generic_reloc, /* special_function */
  1395. "R_MICROMIPS_TLS_TPREL_LO16", /* name */
  1396. true, /* partial_inplace */
  1397. 0x0000ffff, /* src_mask */
  1398. 0x0000ffff, /* dst_mask */
  1399. false), /* pcrel_offset */
  1400. EMPTY_HOWTO (171),
  1401. /* GP- and PC-relative relocations. */
  1402. HOWTO (R_MICROMIPS_GPREL7_S2, /* type */
  1403. 2, /* rightshift */
  1404. 1, /* size (0 = byte, 1 = short, 2 = long) */
  1405. 7, /* bitsize */
  1406. false, /* pc_relative */
  1407. 0, /* bitpos */
  1408. complain_overflow_signed, /* complain_on_overflow */
  1409. _bfd_mips_elf32_gprel16_reloc, /* special_function */
  1410. "R_MICROMIPS_GPREL7_S2", /* name */
  1411. true, /* partial_inplace */
  1412. 0x0000007f, /* src_mask */
  1413. 0x0000007f, /* dst_mask */
  1414. false), /* pcrel_offset */
  1415. HOWTO (R_MICROMIPS_PC23_S2, /* type */
  1416. 2, /* rightshift */
  1417. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1418. 23, /* bitsize */
  1419. true, /* pc_relative */
  1420. 0, /* bitpos */
  1421. complain_overflow_signed, /* complain_on_overflow */
  1422. _bfd_mips_elf_generic_reloc, /* special_function */
  1423. "R_MICROMIPS_PC23_S2", /* name */
  1424. true, /* partial_inplace */
  1425. 0x007fffff, /* src_mask */
  1426. 0x007fffff, /* dst_mask */
  1427. true), /* pcrel_offset */
  1428. };
  1429. /* 16 bit offset for pc-relative branches. */
  1430. static reloc_howto_type elf_mips_gnu_rel16_s2 =
  1431. HOWTO (R_MIPS_GNU_REL16_S2, /* type */
  1432. 2, /* rightshift */
  1433. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1434. 16, /* bitsize */
  1435. true, /* pc_relative */
  1436. 0, /* bitpos */
  1437. complain_overflow_signed, /* complain_on_overflow */
  1438. _bfd_mips_elf_generic_reloc, /* special_function */
  1439. "R_MIPS_GNU_REL16_S2", /* name */
  1440. true, /* partial_inplace */
  1441. 0xffff, /* src_mask */
  1442. 0xffff, /* dst_mask */
  1443. true); /* pcrel_offset */
  1444. /* 32 bit pc-relative. This was a GNU extension used by embedded-PIC.
  1445. It was co-opted by mips-linux for exception-handling data. GCC stopped
  1446. using it in May, 2004, then started using it again for compact unwind
  1447. tables. */
  1448. static reloc_howto_type elf_mips_gnu_pcrel32 =
  1449. HOWTO (R_MIPS_PC32, /* type */
  1450. 0, /* rightshift */
  1451. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1452. 32, /* bitsize */
  1453. true, /* pc_relative */
  1454. 0, /* bitpos */
  1455. complain_overflow_signed, /* complain_on_overflow */
  1456. _bfd_mips_elf_generic_reloc, /* special_function */
  1457. "R_MIPS_PC32", /* name */
  1458. true, /* partial_inplace */
  1459. 0xffffffff, /* src_mask */
  1460. 0xffffffff, /* dst_mask */
  1461. true); /* pcrel_offset */
  1462. /* GNU extension to record C++ vtable hierarchy */
  1463. static reloc_howto_type elf_mips_gnu_vtinherit_howto =
  1464. HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
  1465. 0, /* rightshift */
  1466. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1467. 0, /* bitsize */
  1468. false, /* pc_relative */
  1469. 0, /* bitpos */
  1470. complain_overflow_dont, /* complain_on_overflow */
  1471. NULL, /* special_function */
  1472. "R_MIPS_GNU_VTINHERIT", /* name */
  1473. false, /* partial_inplace */
  1474. 0, /* src_mask */
  1475. 0, /* dst_mask */
  1476. false); /* pcrel_offset */
  1477. /* GNU extension to record C++ vtable member usage */
  1478. static reloc_howto_type elf_mips_gnu_vtentry_howto =
  1479. HOWTO (R_MIPS_GNU_VTENTRY, /* type */
  1480. 0, /* rightshift */
  1481. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1482. 0, /* bitsize */
  1483. false, /* pc_relative */
  1484. 0, /* bitpos */
  1485. complain_overflow_dont, /* complain_on_overflow */
  1486. _bfd_elf_rel_vtable_reloc_fn, /* special_function */
  1487. "R_MIPS_GNU_VTENTRY", /* name */
  1488. false, /* partial_inplace */
  1489. 0, /* src_mask */
  1490. 0, /* dst_mask */
  1491. false); /* pcrel_offset */
  1492. /* Originally a VxWorks extension, but now used for other systems too. */
  1493. static reloc_howto_type elf_mips_copy_howto =
  1494. HOWTO (R_MIPS_COPY, /* type */
  1495. 0, /* rightshift */
  1496. 0, /* this one is variable size */
  1497. 0, /* bitsize */
  1498. false, /* pc_relative */
  1499. 0, /* bitpos */
  1500. complain_overflow_bitfield, /* complain_on_overflow */
  1501. _bfd_mips_elf_generic_reloc, /* special_function */
  1502. "R_MIPS_COPY", /* name */
  1503. false, /* partial_inplace */
  1504. 0x0, /* src_mask */
  1505. 0x0, /* dst_mask */
  1506. false); /* pcrel_offset */
  1507. /* Originally a VxWorks extension, but now used for other systems too. */
  1508. static reloc_howto_type elf_mips_jump_slot_howto =
  1509. HOWTO (R_MIPS_JUMP_SLOT, /* type */
  1510. 0, /* rightshift */
  1511. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1512. 32, /* bitsize */
  1513. false, /* pc_relative */
  1514. 0, /* bitpos */
  1515. complain_overflow_bitfield, /* complain_on_overflow */
  1516. _bfd_mips_elf_generic_reloc, /* special_function */
  1517. "R_MIPS_JUMP_SLOT", /* name */
  1518. false, /* partial_inplace */
  1519. 0x0, /* src_mask */
  1520. 0x0, /* dst_mask */
  1521. false); /* pcrel_offset */
  1522. /* Used in EH tables. */
  1523. static reloc_howto_type elf_mips_eh_howto =
  1524. HOWTO (R_MIPS_EH, /* type */
  1525. 0, /* rightshift */
  1526. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1527. 32, /* bitsize */
  1528. false, /* pc_relative */
  1529. 0, /* bitpos */
  1530. complain_overflow_signed, /* complain_on_overflow */
  1531. _bfd_mips_elf_generic_reloc, /* special_function */
  1532. "R_MIPS_EH", /* name */
  1533. true, /* partial_inplace */
  1534. 0xffffffff, /* src_mask */
  1535. 0xffffffff, /* dst_mask */
  1536. false); /* pcrel_offset */
  1537. /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
  1538. dangerous relocation. */
  1539. static bool
  1540. mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
  1541. {
  1542. unsigned int count;
  1543. asymbol **sym;
  1544. unsigned int i;
  1545. /* If we've already figured out what GP will be, just return it. */
  1546. *pgp = _bfd_get_gp_value (output_bfd);
  1547. if (*pgp)
  1548. return true;
  1549. count = bfd_get_symcount (output_bfd);
  1550. sym = bfd_get_outsymbols (output_bfd);
  1551. /* The linker script will have created a symbol named `_gp' with the
  1552. appropriate value. */
  1553. if (sym == NULL)
  1554. i = count;
  1555. else
  1556. {
  1557. for (i = 0; i < count; i++, sym++)
  1558. {
  1559. register const char *name;
  1560. name = bfd_asymbol_name (*sym);
  1561. if (*name == '_' && strcmp (name, "_gp") == 0)
  1562. {
  1563. *pgp = bfd_asymbol_value (*sym);
  1564. _bfd_set_gp_value (output_bfd, *pgp);
  1565. break;
  1566. }
  1567. }
  1568. }
  1569. if (i >= count)
  1570. {
  1571. /* Only get the error once. */
  1572. *pgp = 4;
  1573. _bfd_set_gp_value (output_bfd, *pgp);
  1574. return false;
  1575. }
  1576. return true;
  1577. }
  1578. /* We have to figure out the gp value, so that we can adjust the
  1579. symbol value correctly. We look up the symbol _gp in the output
  1580. BFD. If we can't find it, we're stuck. We cache it in the ELF
  1581. target data. We don't need to adjust the symbol value for an
  1582. external symbol if we are producing relocatable output. */
  1583. static bfd_reloc_status_type
  1584. mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bool relocatable,
  1585. char **error_message, bfd_vma *pgp)
  1586. {
  1587. if (bfd_is_und_section (symbol->section)
  1588. && ! relocatable)
  1589. {
  1590. *pgp = 0;
  1591. return bfd_reloc_undefined;
  1592. }
  1593. *pgp = _bfd_get_gp_value (output_bfd);
  1594. if (*pgp == 0
  1595. && (! relocatable
  1596. || (symbol->flags & BSF_SECTION_SYM) != 0))
  1597. {
  1598. if (relocatable)
  1599. {
  1600. /* Make up a value. */
  1601. *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
  1602. _bfd_set_gp_value (output_bfd, *pgp);
  1603. }
  1604. else if (!mips_elf_assign_gp (output_bfd, pgp))
  1605. {
  1606. *error_message =
  1607. (char *) _("GP relative relocation when _gp not defined");
  1608. return bfd_reloc_dangerous;
  1609. }
  1610. }
  1611. return bfd_reloc_ok;
  1612. }
  1613. /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
  1614. become the offset from the gp register. This function also handles
  1615. R_MIPS_LITERAL relocations, although those can be handled more
  1616. cleverly because the entries in the .lit8 and .lit4 sections can be
  1617. merged. */
  1618. bfd_reloc_status_type
  1619. _bfd_mips_elf32_gprel16_reloc (bfd *abfd, arelent *reloc_entry,
  1620. asymbol *symbol, void *data,
  1621. asection *input_section, bfd *output_bfd,
  1622. char **error_message)
  1623. {
  1624. bool relocatable;
  1625. bfd_reloc_status_type ret;
  1626. bfd_byte *location;
  1627. bfd_vma gp;
  1628. /* R_MIPS_LITERAL/R_MICROMIPS_LITERAL relocations are defined for local
  1629. symbols only. */
  1630. if (literal_reloc_p (reloc_entry->howto->type)
  1631. && output_bfd != NULL
  1632. && (symbol->flags & BSF_SECTION_SYM) == 0
  1633. && (symbol->flags & BSF_LOCAL) != 0)
  1634. {
  1635. *error_message = (char *)
  1636. _("literal relocation occurs for an external symbol");
  1637. return bfd_reloc_outofrange;
  1638. }
  1639. if (output_bfd != NULL)
  1640. relocatable = true;
  1641. else
  1642. {
  1643. relocatable = false;
  1644. output_bfd = input_section->output_section->owner;
  1645. }
  1646. ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
  1647. &gp);
  1648. if (ret != bfd_reloc_ok)
  1649. return ret;
  1650. location = (bfd_byte *) data + reloc_entry->address;
  1651. _bfd_mips_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, false,
  1652. location);
  1653. ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
  1654. input_section, relocatable,
  1655. data, gp);
  1656. _bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
  1657. location);
  1658. return ret;
  1659. }
  1660. /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
  1661. become the offset from the gp register. */
  1662. static bfd_reloc_status_type
  1663. mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
  1664. void *data, asection *input_section, bfd *output_bfd,
  1665. char **error_message)
  1666. {
  1667. bool relocatable;
  1668. bfd_reloc_status_type ret;
  1669. bfd_vma gp;
  1670. /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
  1671. if (output_bfd != NULL
  1672. && (symbol->flags & BSF_SECTION_SYM) == 0
  1673. && (symbol->flags & BSF_LOCAL) != 0)
  1674. {
  1675. *error_message = (char *)
  1676. _("32bits gp relative relocation occurs for an external symbol");
  1677. return bfd_reloc_outofrange;
  1678. }
  1679. if (output_bfd != NULL)
  1680. relocatable = true;
  1681. else
  1682. {
  1683. relocatable = false;
  1684. output_bfd = input_section->output_section->owner;
  1685. }
  1686. ret = mips_elf_final_gp (output_bfd, symbol, relocatable,
  1687. error_message, &gp);
  1688. if (ret != bfd_reloc_ok)
  1689. return ret;
  1690. return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
  1691. relocatable, data, gp);
  1692. }
  1693. static bfd_reloc_status_type
  1694. gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
  1695. asection *input_section, bool relocatable,
  1696. void *data, bfd_vma gp)
  1697. {
  1698. bfd_vma relocation;
  1699. bfd_vma val;
  1700. if (bfd_is_com_section (symbol->section))
  1701. relocation = 0;
  1702. else
  1703. relocation = symbol->value;
  1704. relocation += symbol->section->output_section->vma;
  1705. relocation += symbol->section->output_offset;
  1706. if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
  1707. return bfd_reloc_outofrange;
  1708. /* Set val to the offset into the section or symbol. */
  1709. val = reloc_entry->addend;
  1710. if (reloc_entry->howto->partial_inplace)
  1711. val += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
  1712. /* Adjust val for the final section location and GP value. If we
  1713. are producing relocatable output, we don't want to do this for
  1714. an external symbol. */
  1715. if (! relocatable
  1716. || (symbol->flags & BSF_SECTION_SYM) != 0)
  1717. val += relocation - gp;
  1718. if (reloc_entry->howto->partial_inplace)
  1719. bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
  1720. else
  1721. reloc_entry->addend = val;
  1722. if (relocatable)
  1723. reloc_entry->address += input_section->output_offset;
  1724. return bfd_reloc_ok;
  1725. }
  1726. /* Handle a 64 bit reloc in a 32 bit MIPS ELF file. These are
  1727. generated when addresses are 64 bits. The upper 32 bits are a simple
  1728. sign extension. */
  1729. static bfd_reloc_status_type
  1730. mips32_64bit_reloc (bfd *abfd, arelent *reloc_entry,
  1731. asymbol *symbol ATTRIBUTE_UNUSED,
  1732. void *data, asection *input_section,
  1733. bfd *output_bfd, char **error_message)
  1734. {
  1735. bfd_reloc_status_type r;
  1736. arelent reloc32;
  1737. unsigned long val;
  1738. bfd_size_type addr;
  1739. /* Do a normal 32 bit relocation on the lower 32 bits. */
  1740. reloc32 = *reloc_entry;
  1741. if (bfd_big_endian (abfd))
  1742. reloc32.address += 4;
  1743. reloc32.howto = &elf_mips_howto_table_rel[R_MIPS_32];
  1744. r = bfd_perform_relocation (abfd, &reloc32, data, input_section,
  1745. output_bfd, error_message);
  1746. /* Sign extend into the upper 32 bits. */
  1747. val = bfd_get_32 (abfd, (bfd_byte *) data + reloc32.address);
  1748. if ((val & 0x80000000) != 0)
  1749. val = 0xffffffff;
  1750. else
  1751. val = 0;
  1752. addr = reloc_entry->address;
  1753. if (bfd_little_endian (abfd))
  1754. addr += 4;
  1755. bfd_put_32 (abfd, val, (bfd_byte *) data + addr);
  1756. return r;
  1757. }
  1758. /* Handle a mips16 GP relative reloc. */
  1759. static bfd_reloc_status_type
  1760. mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
  1761. void *data, asection *input_section, bfd *output_bfd,
  1762. char **error_message)
  1763. {
  1764. bool relocatable;
  1765. bfd_reloc_status_type ret;
  1766. bfd_byte *location;
  1767. bfd_vma gp;
  1768. /* If we're relocating, and this is an external symbol, we don't want
  1769. to change anything. */
  1770. if (output_bfd != NULL
  1771. && (symbol->flags & BSF_SECTION_SYM) == 0
  1772. && (symbol->flags & BSF_LOCAL) != 0)
  1773. {
  1774. reloc_entry->address += input_section->output_offset;
  1775. return bfd_reloc_ok;
  1776. }
  1777. if (output_bfd != NULL)
  1778. relocatable = true;
  1779. else
  1780. {
  1781. relocatable = false;
  1782. output_bfd = input_section->output_section->owner;
  1783. }
  1784. ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
  1785. &gp);
  1786. if (ret != bfd_reloc_ok)
  1787. return ret;
  1788. location = (bfd_byte *) data + reloc_entry->address;
  1789. _bfd_mips_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, false,
  1790. location);
  1791. ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
  1792. input_section, relocatable,
  1793. data, gp);
  1794. _bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
  1795. location);
  1796. return ret;
  1797. }
  1798. /* A mapping from BFD reloc types to MIPS ELF reloc types. */
  1799. struct elf_reloc_map {
  1800. bfd_reloc_code_real_type bfd_val;
  1801. enum elf_mips_reloc_type elf_val;
  1802. };
  1803. static const struct elf_reloc_map mips_reloc_map[] =
  1804. {
  1805. { BFD_RELOC_NONE, R_MIPS_NONE },
  1806. { BFD_RELOC_16, R_MIPS_16 },
  1807. { BFD_RELOC_32, R_MIPS_32 },
  1808. /* There is no BFD reloc for R_MIPS_REL32. */
  1809. { BFD_RELOC_64, R_MIPS_64 },
  1810. { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
  1811. { BFD_RELOC_HI16_S, R_MIPS_HI16 },
  1812. { BFD_RELOC_LO16, R_MIPS_LO16 },
  1813. { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
  1814. { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
  1815. { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
  1816. { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
  1817. { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
  1818. { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
  1819. { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
  1820. { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
  1821. { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
  1822. { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
  1823. { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
  1824. { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
  1825. { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
  1826. { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
  1827. { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
  1828. { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
  1829. { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
  1830. { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
  1831. { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
  1832. { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
  1833. { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
  1834. { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
  1835. { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
  1836. { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
  1837. { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
  1838. { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
  1839. { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
  1840. { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 },
  1841. { BFD_RELOC_MIPS_21_PCREL_S2, R_MIPS_PC21_S2 },
  1842. { BFD_RELOC_MIPS_26_PCREL_S2, R_MIPS_PC26_S2 },
  1843. { BFD_RELOC_MIPS_18_PCREL_S3, R_MIPS_PC18_S3 },
  1844. { BFD_RELOC_MIPS_19_PCREL_S2, R_MIPS_PC19_S2 },
  1845. { BFD_RELOC_HI16_S_PCREL, R_MIPS_PCHI16 },
  1846. { BFD_RELOC_LO16_PCREL, R_MIPS_PCLO16 }
  1847. };
  1848. static const struct elf_reloc_map mips16_reloc_map[] =
  1849. {
  1850. { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
  1851. { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
  1852. { BFD_RELOC_MIPS16_GOT16, R_MIPS16_GOT16 - R_MIPS16_min },
  1853. { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
  1854. { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
  1855. { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
  1856. { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min },
  1857. { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min },
  1858. { BFD_RELOC_MIPS16_TLS_DTPREL_HI16,
  1859. R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min },
  1860. { BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
  1861. R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min },
  1862. { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min },
  1863. { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min },
  1864. { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min },
  1865. { BFD_RELOC_MIPS16_16_PCREL_S1, R_MIPS16_PC16_S1 - R_MIPS16_min }
  1866. };
  1867. static const struct elf_reloc_map micromips_reloc_map[] =
  1868. {
  1869. { BFD_RELOC_MICROMIPS_JMP, R_MICROMIPS_26_S1 - R_MICROMIPS_min },
  1870. { BFD_RELOC_MICROMIPS_HI16_S, R_MICROMIPS_HI16 - R_MICROMIPS_min },
  1871. { BFD_RELOC_MICROMIPS_LO16, R_MICROMIPS_LO16 - R_MICROMIPS_min },
  1872. { BFD_RELOC_MICROMIPS_GPREL16, R_MICROMIPS_GPREL16 - R_MICROMIPS_min },
  1873. { BFD_RELOC_MICROMIPS_LITERAL, R_MICROMIPS_LITERAL - R_MICROMIPS_min },
  1874. { BFD_RELOC_MICROMIPS_GOT16, R_MICROMIPS_GOT16 - R_MICROMIPS_min },
  1875. { BFD_RELOC_MICROMIPS_7_PCREL_S1, R_MICROMIPS_PC7_S1 - R_MICROMIPS_min },
  1876. { BFD_RELOC_MICROMIPS_10_PCREL_S1, R_MICROMIPS_PC10_S1 - R_MICROMIPS_min },
  1877. { BFD_RELOC_MICROMIPS_16_PCREL_S1, R_MICROMIPS_PC16_S1 - R_MICROMIPS_min },
  1878. { BFD_RELOC_MICROMIPS_CALL16, R_MICROMIPS_CALL16 - R_MICROMIPS_min },
  1879. { BFD_RELOC_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_DISP - R_MICROMIPS_min },
  1880. { BFD_RELOC_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE - R_MICROMIPS_min },
  1881. { BFD_RELOC_MICROMIPS_GOT_OFST, R_MICROMIPS_GOT_OFST - R_MICROMIPS_min },
  1882. { BFD_RELOC_MICROMIPS_GOT_HI16, R_MICROMIPS_GOT_HI16 - R_MICROMIPS_min },
  1883. { BFD_RELOC_MICROMIPS_GOT_LO16, R_MICROMIPS_GOT_LO16 - R_MICROMIPS_min },
  1884. { BFD_RELOC_MICROMIPS_SUB, R_MICROMIPS_SUB - R_MICROMIPS_min },
  1885. { BFD_RELOC_MICROMIPS_HIGHER, R_MICROMIPS_HIGHER - R_MICROMIPS_min },
  1886. { BFD_RELOC_MICROMIPS_HIGHEST, R_MICROMIPS_HIGHEST - R_MICROMIPS_min },
  1887. { BFD_RELOC_MICROMIPS_CALL_HI16, R_MICROMIPS_CALL_HI16 - R_MICROMIPS_min },
  1888. { BFD_RELOC_MICROMIPS_CALL_LO16, R_MICROMIPS_CALL_LO16 - R_MICROMIPS_min },
  1889. { BFD_RELOC_MICROMIPS_SCN_DISP, R_MICROMIPS_SCN_DISP - R_MICROMIPS_min },
  1890. { BFD_RELOC_MICROMIPS_JALR, R_MICROMIPS_JALR - R_MICROMIPS_min },
  1891. /* There is no BFD reloc for R_MICROMIPS_HI0_LO16. */
  1892. { BFD_RELOC_MICROMIPS_TLS_GD, R_MICROMIPS_TLS_GD - R_MICROMIPS_min },
  1893. { BFD_RELOC_MICROMIPS_TLS_LDM, R_MICROMIPS_TLS_LDM - R_MICROMIPS_min },
  1894. { BFD_RELOC_MICROMIPS_TLS_DTPREL_HI16,
  1895. R_MICROMIPS_TLS_DTPREL_HI16 - R_MICROMIPS_min },
  1896. { BFD_RELOC_MICROMIPS_TLS_DTPREL_LO16,
  1897. R_MICROMIPS_TLS_DTPREL_LO16 - R_MICROMIPS_min },
  1898. { BFD_RELOC_MICROMIPS_TLS_GOTTPREL,
  1899. R_MICROMIPS_TLS_GOTTPREL - R_MICROMIPS_min },
  1900. { BFD_RELOC_MICROMIPS_TLS_TPREL_HI16,
  1901. R_MICROMIPS_TLS_TPREL_HI16 - R_MICROMIPS_min },
  1902. { BFD_RELOC_MICROMIPS_TLS_TPREL_LO16,
  1903. R_MICROMIPS_TLS_TPREL_LO16 - R_MICROMIPS_min },
  1904. /* There is no BFD reloc for R_MICROMIPS_GPREL7_S2. */
  1905. /* There is no BFD reloc for R_MICROMIPS_PC23_S2. */
  1906. };
  1907. /* Given a BFD reloc type, return a howto structure. */
  1908. static reloc_howto_type *
  1909. bfd_elf32_bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code)
  1910. {
  1911. unsigned int i;
  1912. reloc_howto_type *howto_table = elf_mips_howto_table_rel;
  1913. reloc_howto_type *howto16_table = elf_mips16_howto_table_rel;
  1914. reloc_howto_type *howto_micromips_table = elf_micromips_howto_table_rel;
  1915. for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
  1916. i++)
  1917. {
  1918. if (mips_reloc_map[i].bfd_val == code)
  1919. return &howto_table[(int) mips_reloc_map[i].elf_val];
  1920. }
  1921. for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
  1922. i++)
  1923. {
  1924. if (mips16_reloc_map[i].bfd_val == code)
  1925. return &howto16_table[(int) mips16_reloc_map[i].elf_val];
  1926. }
  1927. for (i = 0; i < sizeof (micromips_reloc_map) / sizeof (struct elf_reloc_map);
  1928. i++)
  1929. {
  1930. if (micromips_reloc_map[i].bfd_val == code)
  1931. return &howto_micromips_table[(int) micromips_reloc_map[i].elf_val];
  1932. }
  1933. switch (code)
  1934. {
  1935. default:
  1936. bfd_set_error (bfd_error_bad_value);
  1937. return NULL;
  1938. case BFD_RELOC_CTOR:
  1939. /* We need to handle BFD_RELOC_CTOR specially.
  1940. Select the right relocation (R_MIPS_32 or R_MIPS_64) based on the
  1941. size of addresses of the ABI. */
  1942. if ((elf_elfheader (abfd)->e_flags & (E_MIPS_ABI_O64
  1943. | E_MIPS_ABI_EABI64)) != 0)
  1944. return &elf_mips_ctor64_howto;
  1945. else
  1946. return &howto_table[(int) R_MIPS_32];
  1947. case BFD_RELOC_VTABLE_INHERIT:
  1948. return &elf_mips_gnu_vtinherit_howto;
  1949. case BFD_RELOC_VTABLE_ENTRY:
  1950. return &elf_mips_gnu_vtentry_howto;
  1951. case BFD_RELOC_32_PCREL:
  1952. return &elf_mips_gnu_pcrel32;
  1953. case BFD_RELOC_MIPS_COPY:
  1954. return &elf_mips_copy_howto;
  1955. case BFD_RELOC_MIPS_JUMP_SLOT:
  1956. return &elf_mips_jump_slot_howto;
  1957. case BFD_RELOC_MIPS_EH:
  1958. return &elf_mips_eh_howto;
  1959. }
  1960. }
  1961. static reloc_howto_type *
  1962. bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
  1963. const char *r_name)
  1964. {
  1965. unsigned int i;
  1966. for (i = 0;
  1967. i < (sizeof (elf_mips_howto_table_rel)
  1968. / sizeof (elf_mips_howto_table_rel[0]));
  1969. i++)
  1970. if (elf_mips_howto_table_rel[i].name != NULL
  1971. && strcasecmp (elf_mips_howto_table_rel[i].name, r_name) == 0)
  1972. return &elf_mips_howto_table_rel[i];
  1973. for (i = 0;
  1974. i < (sizeof (elf_mips16_howto_table_rel)
  1975. / sizeof (elf_mips16_howto_table_rel[0]));
  1976. i++)
  1977. if (elf_mips16_howto_table_rel[i].name != NULL
  1978. && strcasecmp (elf_mips16_howto_table_rel[i].name, r_name) == 0)
  1979. return &elf_mips16_howto_table_rel[i];
  1980. for (i = 0;
  1981. i < (sizeof (elf_micromips_howto_table_rel)
  1982. / sizeof (elf_micromips_howto_table_rel[0]));
  1983. i++)
  1984. if (elf_micromips_howto_table_rel[i].name != NULL
  1985. && strcasecmp (elf_micromips_howto_table_rel[i].name, r_name) == 0)
  1986. return &elf_micromips_howto_table_rel[i];
  1987. if (strcasecmp (elf_mips_gnu_pcrel32.name, r_name) == 0)
  1988. return &elf_mips_gnu_pcrel32;
  1989. if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0)
  1990. return &elf_mips_gnu_rel16_s2;
  1991. if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0)
  1992. return &elf_mips_gnu_vtinherit_howto;
  1993. if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0)
  1994. return &elf_mips_gnu_vtentry_howto;
  1995. if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
  1996. return &elf_mips_copy_howto;
  1997. if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
  1998. return &elf_mips_jump_slot_howto;
  1999. if (strcasecmp (elf_mips_eh_howto.name, r_name) == 0)
  2000. return &elf_mips_eh_howto;
  2001. return NULL;
  2002. }
  2003. /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
  2004. static reloc_howto_type *
  2005. mips_elf32_rtype_to_howto (bfd *abfd,
  2006. unsigned int r_type,
  2007. bool rela_p ATTRIBUTE_UNUSED)
  2008. {
  2009. reloc_howto_type *howto = NULL;
  2010. switch (r_type)
  2011. {
  2012. case R_MIPS_GNU_VTINHERIT:
  2013. return &elf_mips_gnu_vtinherit_howto;
  2014. case R_MIPS_GNU_VTENTRY:
  2015. return &elf_mips_gnu_vtentry_howto;
  2016. case R_MIPS_GNU_REL16_S2:
  2017. return &elf_mips_gnu_rel16_s2;
  2018. case R_MIPS_PC32:
  2019. return &elf_mips_gnu_pcrel32;
  2020. case R_MIPS_COPY:
  2021. return &elf_mips_copy_howto;
  2022. case R_MIPS_JUMP_SLOT:
  2023. return &elf_mips_jump_slot_howto;
  2024. case R_MIPS_EH:
  2025. return &elf_mips_eh_howto;
  2026. default:
  2027. if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max)
  2028. howto = &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min];
  2029. if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
  2030. howto = &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
  2031. if (r_type < R_MIPS_max)
  2032. howto = &elf_mips_howto_table_rel[r_type];
  2033. if (howto != NULL && howto->name != NULL)
  2034. return howto;
  2035. _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
  2036. abfd, r_type);
  2037. bfd_set_error (bfd_error_bad_value);
  2038. return NULL;
  2039. }
  2040. }
  2041. /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
  2042. static bool
  2043. mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
  2044. {
  2045. unsigned int r_type;
  2046. r_type = ELF32_R_TYPE (dst->r_info);
  2047. cache_ptr->howto = mips_elf32_rtype_to_howto (abfd, r_type, false);
  2048. if (cache_ptr->howto == NULL)
  2049. return false;
  2050. /* The addend for a GPREL16 or LITERAL relocation comes from the GP
  2051. value for the object file. We get the addend now, rather than
  2052. when we do the relocation, because the symbol manipulations done
  2053. by the linker may cause us to lose track of the input BFD. */
  2054. if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
  2055. && (gprel16_reloc_p (r_type) || literal_reloc_p (r_type)))
  2056. cache_ptr->addend = elf_gp (abfd);
  2057. return true;
  2058. }
  2059. /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
  2060. static bool
  2061. mips_info_to_howto_rela (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
  2062. {
  2063. return mips_info_to_howto_rel (abfd, cache_ptr, dst);
  2064. /* If we ever need to do any extra processing with dst->r_addend
  2065. (the field omitted in an Elf_Internal_Rel) we can do it here. */
  2066. }
  2067. /* Determine whether a symbol is global for the purposes of splitting
  2068. the symbol table into global symbols and local symbols. At least
  2069. on Irix 5, this split must be between section symbols and all other
  2070. symbols. On most ELF targets the split is between static symbols
  2071. and externally visible symbols. */
  2072. static bool
  2073. mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
  2074. {
  2075. if (SGI_COMPAT (abfd))
  2076. return (sym->flags & BSF_SECTION_SYM) == 0;
  2077. else
  2078. return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
  2079. || bfd_is_und_section (bfd_asymbol_section (sym))
  2080. || bfd_is_com_section (bfd_asymbol_section (sym)));
  2081. }
  2082. /* Likewise, return TRUE if the symbol table split overall must be
  2083. between section symbols and all other symbols. */
  2084. static bool
  2085. mips_elf32_elfsym_local_is_section (bfd *abfd)
  2086. {
  2087. return SGI_COMPAT (abfd);
  2088. }
  2089. /* Set the right machine number for a MIPS ELF file. */
  2090. static bool
  2091. mips_elf32_object_p (bfd *abfd)
  2092. {
  2093. unsigned long mach;
  2094. if (ABI_N32_P (abfd))
  2095. return false;
  2096. /* Irix 5 and 6 are broken. Object file symbol tables are not always
  2097. sorted correctly such that local symbols precede global symbols,
  2098. and the sh_info field in the symbol table is not always right. */
  2099. if (SGI_COMPAT (abfd))
  2100. elf_bad_symtab (abfd) = true;
  2101. mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
  2102. bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
  2103. return true;
  2104. }
  2105. /* MIPS ELF local labels start with '$', not 'L'. */
  2106. static bool
  2107. mips_elf_is_local_label_name (bfd *abfd, const char *name)
  2108. {
  2109. if (name[0] == '$')
  2110. return true;
  2111. /* On Irix 6, the labels go back to starting with '.', so we accept
  2112. the generic ELF local label syntax as well. */
  2113. return _bfd_elf_is_local_label_name (abfd, name);
  2114. }
  2115. /* Support for core dump NOTE sections. */
  2116. static bool
  2117. elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
  2118. {
  2119. int offset;
  2120. unsigned int size;
  2121. switch (note->descsz)
  2122. {
  2123. default:
  2124. return false;
  2125. case 256: /* Linux/MIPS */
  2126. /* pr_cursig */
  2127. elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
  2128. /* pr_pid */
  2129. elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
  2130. /* pr_reg */
  2131. offset = 72;
  2132. size = 180;
  2133. break;
  2134. }
  2135. /* Make a ".reg/999" section. */
  2136. return _bfd_elfcore_make_pseudosection (abfd, ".reg",
  2137. size, note->descpos + offset);
  2138. }
  2139. static bool
  2140. elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
  2141. {
  2142. switch (note->descsz)
  2143. {
  2144. default:
  2145. return false;
  2146. case 128: /* Linux/MIPS elf_prpsinfo */
  2147. elf_tdata (abfd)->core->pid
  2148. = bfd_get_32 (abfd, note->descdata + 16);
  2149. elf_tdata (abfd)->core->program
  2150. = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
  2151. elf_tdata (abfd)->core->command
  2152. = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
  2153. }
  2154. /* Note that for some reason, a spurious space is tacked
  2155. onto the end of the args in some (at least one anyway)
  2156. implementations, so strip it off if it exists. */
  2157. {
  2158. char *command = elf_tdata (abfd)->core->command;
  2159. int n = strlen (command);
  2160. if (0 < n && command[n - 1] == ' ')
  2161. command[n - 1] = '\0';
  2162. }
  2163. return true;
  2164. }
  2165. /* Write Linux core PRSTATUS note into core file. */
  2166. static char *
  2167. elf32_mips_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type,
  2168. ...)
  2169. {
  2170. switch (note_type)
  2171. {
  2172. default:
  2173. return NULL;
  2174. case NT_PRPSINFO:
  2175. BFD_FAIL ();
  2176. return NULL;
  2177. case NT_PRSTATUS:
  2178. {
  2179. char data[256];
  2180. va_list ap;
  2181. long pid;
  2182. int cursig;
  2183. const void *greg;
  2184. va_start (ap, note_type);
  2185. memset (data, 0, 72);
  2186. pid = va_arg (ap, long);
  2187. bfd_put_32 (abfd, pid, data + 24);
  2188. cursig = va_arg (ap, int);
  2189. bfd_put_16 (abfd, cursig, data + 12);
  2190. greg = va_arg (ap, const void *);
  2191. memcpy (data + 72, greg, 180);
  2192. memset (data + 252, 0, 4);
  2193. va_end (ap);
  2194. return elfcore_write_note (abfd, buf, bufsiz,
  2195. "CORE", note_type, data, sizeof (data));
  2196. }
  2197. }
  2198. }
  2199. /* Remove the magic _gp_disp symbol from the symbol tables. */
  2200. static bool
  2201. elf32_mips_fixup_symbol (struct bfd_link_info *info,
  2202. struct elf_link_hash_entry *h)
  2203. {
  2204. if (strcmp (h->root.root.string, "_gp_disp") == 0)
  2205. _bfd_elf_link_hash_hide_symbol (info, h, true);
  2206. return true;
  2207. }
  2208. /* Depending on the target vector we generate some version of Irix
  2209. executables or "normal" MIPS ELF ABI executables. */
  2210. static irix_compat_t
  2211. elf32_mips_irix_compat (bfd *abfd)
  2212. {
  2213. if ((abfd->xvec == &mips_elf32_be_vec)
  2214. || (abfd->xvec == &mips_elf32_le_vec))
  2215. return ict_irix5;
  2216. else
  2217. return ict_none;
  2218. }
  2219. /* ECOFF swapping routines. These are used when dealing with the
  2220. .mdebug section, which is in the ECOFF debugging format. */
  2221. static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
  2222. /* Symbol table magic number. */
  2223. magicSym,
  2224. /* Alignment of debugging information. E.g., 4. */
  2225. 4,
  2226. /* Sizes of external symbolic information. */
  2227. sizeof (struct hdr_ext),
  2228. sizeof (struct dnr_ext),
  2229. sizeof (struct pdr_ext),
  2230. sizeof (struct sym_ext),
  2231. sizeof (struct opt_ext),
  2232. sizeof (struct fdr_ext),
  2233. sizeof (struct rfd_ext),
  2234. sizeof (struct ext_ext),
  2235. /* Functions to swap in external symbolic data. */
  2236. ecoff_swap_hdr_in,
  2237. ecoff_swap_dnr_in,
  2238. ecoff_swap_pdr_in,
  2239. ecoff_swap_sym_in,
  2240. ecoff_swap_opt_in,
  2241. ecoff_swap_fdr_in,
  2242. ecoff_swap_rfd_in,
  2243. ecoff_swap_ext_in,
  2244. _bfd_ecoff_swap_tir_in,
  2245. _bfd_ecoff_swap_rndx_in,
  2246. /* Functions to swap out external symbolic data. */
  2247. ecoff_swap_hdr_out,
  2248. ecoff_swap_dnr_out,
  2249. ecoff_swap_pdr_out,
  2250. ecoff_swap_sym_out,
  2251. ecoff_swap_opt_out,
  2252. ecoff_swap_fdr_out,
  2253. ecoff_swap_rfd_out,
  2254. ecoff_swap_ext_out,
  2255. _bfd_ecoff_swap_tir_out,
  2256. _bfd_ecoff_swap_rndx_out,
  2257. /* Function to read in symbolic data. */
  2258. _bfd_mips_elf_read_ecoff_info
  2259. };
  2260. #define ELF_ARCH bfd_arch_mips
  2261. #define ELF_TARGET_ID MIPS_ELF_DATA
  2262. #define ELF_MACHINE_CODE EM_MIPS
  2263. #define elf_backend_collect true
  2264. #define elf_backend_type_change_ok true
  2265. #define elf_backend_can_gc_sections true
  2266. #define elf_backend_gc_mark_extra_sections \
  2267. _bfd_mips_elf_gc_mark_extra_sections
  2268. #define elf_info_to_howto mips_info_to_howto_rela
  2269. #define elf_info_to_howto_rel mips_info_to_howto_rel
  2270. #define elf_backend_sym_is_global mips_elf_sym_is_global
  2271. #define elf_backend_object_p mips_elf32_object_p
  2272. #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
  2273. #define elf_backend_section_processing _bfd_mips_elf_section_processing
  2274. #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
  2275. #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
  2276. #define elf_backend_section_from_bfd_section \
  2277. _bfd_mips_elf_section_from_bfd_section
  2278. #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
  2279. #define elf_backend_link_output_symbol_hook \
  2280. _bfd_mips_elf_link_output_symbol_hook
  2281. #define elf_backend_create_dynamic_sections \
  2282. _bfd_mips_elf_create_dynamic_sections
  2283. #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
  2284. #define elf_backend_merge_symbol_attribute \
  2285. _bfd_mips_elf_merge_symbol_attribute
  2286. #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
  2287. #define elf_backend_adjust_dynamic_symbol \
  2288. _bfd_mips_elf_adjust_dynamic_symbol
  2289. #define elf_backend_always_size_sections \
  2290. _bfd_mips_elf_always_size_sections
  2291. #define elf_backend_size_dynamic_sections \
  2292. _bfd_mips_elf_size_dynamic_sections
  2293. #define elf_backend_init_index_section _bfd_elf_init_1_index_section
  2294. #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
  2295. #define elf_backend_finish_dynamic_symbol \
  2296. _bfd_mips_elf_finish_dynamic_symbol
  2297. #define elf_backend_finish_dynamic_sections \
  2298. _bfd_mips_elf_finish_dynamic_sections
  2299. #define elf_backend_final_write_processing \
  2300. _bfd_mips_elf_final_write_processing
  2301. #define elf_backend_additional_program_headers \
  2302. _bfd_mips_elf_additional_program_headers
  2303. #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
  2304. #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
  2305. #define elf_backend_copy_indirect_symbol \
  2306. _bfd_mips_elf_copy_indirect_symbol
  2307. #define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
  2308. #define elf_backend_fixup_symbol elf32_mips_fixup_symbol
  2309. #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
  2310. #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
  2311. #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
  2312. #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
  2313. #define elf_backend_want_dynrelro 1
  2314. #define elf_backend_may_use_rel_p 1
  2315. #define elf_backend_may_use_rela_p 0
  2316. #define elf_backend_default_use_rela_p 0
  2317. #define elf_backend_sign_extend_vma true
  2318. #define elf_backend_plt_readonly 1
  2319. #define elf_backend_discard_info _bfd_mips_elf_discard_info
  2320. #define elf_backend_ignore_discarded_relocs \
  2321. _bfd_mips_elf_ignore_discarded_relocs
  2322. #define elf_backend_write_section _bfd_mips_elf_write_section
  2323. #define elf_backend_elfsym_local_is_section \
  2324. mips_elf32_elfsym_local_is_section
  2325. #define elf_backend_mips_irix_compat elf32_mips_irix_compat
  2326. #define elf_backend_mips_rtype_to_howto mips_elf32_rtype_to_howto
  2327. #define elf_backend_sort_relocs_p _bfd_mips_elf_sort_relocs_p
  2328. #define bfd_elf32_bfd_is_local_label_name \
  2329. mips_elf_is_local_label_name
  2330. #define bfd_elf32_bfd_is_target_special_symbol \
  2331. _bfd_mips_elf_is_target_special_symbol
  2332. #define bfd_elf32_get_synthetic_symtab _bfd_mips_elf_get_synthetic_symtab
  2333. #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
  2334. #define bfd_elf32_find_inliner_info _bfd_mips_elf_find_inliner_info
  2335. #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
  2336. #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
  2337. #define bfd_elf32_bfd_get_relocated_section_contents \
  2338. _bfd_elf_mips_get_relocated_section_contents
  2339. #define bfd_elf32_bfd_link_hash_table_create \
  2340. _bfd_mips_elf_link_hash_table_create
  2341. #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
  2342. #define bfd_elf32_bfd_merge_private_bfd_data \
  2343. _bfd_mips_elf_merge_private_bfd_data
  2344. #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
  2345. #define bfd_elf32_bfd_print_private_bfd_data \
  2346. _bfd_mips_elf_print_private_bfd_data
  2347. #define bfd_elf32_bfd_relax_section _bfd_mips_elf_relax_section
  2348. #define bfd_elf32_mkobject _bfd_mips_elf_mkobject
  2349. /* Support for SGI-ish mips targets. */
  2350. #define TARGET_LITTLE_SYM mips_elf32_le_vec
  2351. #define TARGET_LITTLE_NAME "elf32-littlemips"
  2352. #define TARGET_BIG_SYM mips_elf32_be_vec
  2353. #define TARGET_BIG_NAME "elf32-bigmips"
  2354. /* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses
  2355. a value of 0x1000, and we are compatible. */
  2356. #define ELF_MAXPAGESIZE 0x1000
  2357. #define ELF_COMMONPAGESIZE 0x1000
  2358. #include "elf32-target.h"
  2359. /* Support for traditional mips targets. */
  2360. #undef TARGET_LITTLE_SYM
  2361. #undef TARGET_LITTLE_NAME
  2362. #undef TARGET_BIG_SYM
  2363. #undef TARGET_BIG_NAME
  2364. #undef ELF_MAXPAGESIZE
  2365. #undef ELF_COMMONPAGESIZE
  2366. #define TARGET_LITTLE_SYM mips_elf32_trad_le_vec
  2367. #define TARGET_LITTLE_NAME "elf32-tradlittlemips"
  2368. #define TARGET_BIG_SYM mips_elf32_trad_be_vec
  2369. #define TARGET_BIG_NAME "elf32-tradbigmips"
  2370. /* The MIPS ABI says at Page 5-1:
  2371. Virtual addresses and file offsets for MIPS segments are congruent
  2372. modulo 64 KByte (0x10000) or larger powers of 2. Because 64 KBytes
  2373. is the maximum page size, the files are suitable for paging
  2374. regardless of physical page size. */
  2375. #define ELF_MAXPAGESIZE 0x10000
  2376. #define ELF_COMMONPAGESIZE 0x1000
  2377. #define elf32_bed elf32_tradbed
  2378. #undef elf_backend_write_core_note
  2379. #define elf_backend_write_core_note elf32_mips_write_core_note
  2380. /* Include the target file again for this target. */
  2381. #include "elf32-target.h"
  2382. /* FreeBSD support. */
  2383. #undef TARGET_LITTLE_SYM
  2384. #undef TARGET_LITTLE_NAME
  2385. #undef TARGET_BIG_SYM
  2386. #undef TARGET_BIG_NAME
  2387. #define TARGET_LITTLE_SYM mips_elf32_tradfbsd_le_vec
  2388. #define TARGET_LITTLE_NAME "elf32-tradlittlemips-freebsd"
  2389. #define TARGET_BIG_SYM mips_elf32_tradfbsd_be_vec
  2390. #define TARGET_BIG_NAME "elf32-tradbigmips-freebsd"
  2391. #undef ELF_OSABI
  2392. #define ELF_OSABI ELFOSABI_FREEBSD
  2393. #undef elf32_bed
  2394. #define elf32_bed elf32_fbsd_tradbed
  2395. #undef elf_backend_write_core_note
  2396. #include "elf32-target.h"
  2397. /* Implement elf_backend_final_write_processing for VxWorks. */
  2398. static bool
  2399. mips_vxworks_final_write_processing (bfd *abfd)
  2400. {
  2401. _bfd_mips_final_write_processing (abfd);
  2402. return elf_vxworks_final_write_processing (abfd);
  2403. }
  2404. #undef TARGET_LITTLE_SYM
  2405. #undef TARGET_LITTLE_NAME
  2406. #undef TARGET_BIG_SYM
  2407. #undef TARGET_BIG_NAME
  2408. #undef ELF_MAXPAGESIZE
  2409. #undef ELF_COMMONPAGESIZE
  2410. #define TARGET_LITTLE_SYM mips_elf32_vxworks_le_vec
  2411. #define TARGET_LITTLE_NAME "elf32-littlemips-vxworks"
  2412. #define TARGET_BIG_SYM mips_elf32_vxworks_be_vec
  2413. #define TARGET_BIG_NAME "elf32-bigmips-vxworks"
  2414. #undef ELF_OSABI
  2415. #undef elf32_bed
  2416. #define elf32_bed elf32_mips_vxworks_bed
  2417. #define ELF_MAXPAGESIZE 0x1000
  2418. #define ELF_COMMONPAGESIZE 0x1000
  2419. #undef ELF_TARGET_OS
  2420. #define ELF_TARGET_OS is_vxworks
  2421. #undef elf_backend_want_got_plt
  2422. #define elf_backend_want_got_plt 1
  2423. #undef elf_backend_want_plt_sym
  2424. #define elf_backend_want_plt_sym 1
  2425. #undef elf_backend_may_use_rel_p
  2426. #define elf_backend_may_use_rel_p 0
  2427. #undef elf_backend_may_use_rela_p
  2428. #define elf_backend_may_use_rela_p 1
  2429. #undef elf_backend_default_use_rela_p
  2430. #define elf_backend_default_use_rela_p 1
  2431. #undef elf_backend_got_header_size
  2432. #define elf_backend_got_header_size (4 * 3)
  2433. #undef elf_backend_dtrel_excludes_plt
  2434. #define elf_backend_dtrel_excludes_plt 1
  2435. #undef elf_backend_finish_dynamic_symbol
  2436. #define elf_backend_finish_dynamic_symbol \
  2437. _bfd_mips_vxworks_finish_dynamic_symbol
  2438. #undef bfd_elf32_bfd_link_hash_table_create
  2439. #define bfd_elf32_bfd_link_hash_table_create \
  2440. _bfd_mips_vxworks_link_hash_table_create
  2441. #undef elf_backend_add_symbol_hook
  2442. #define elf_backend_add_symbol_hook \
  2443. elf_vxworks_add_symbol_hook
  2444. #undef elf_backend_link_output_symbol_hook
  2445. #define elf_backend_link_output_symbol_hook \
  2446. elf_vxworks_link_output_symbol_hook
  2447. #undef elf_backend_emit_relocs
  2448. #define elf_backend_emit_relocs \
  2449. elf_vxworks_emit_relocs
  2450. #undef elf_backend_final_write_processing
  2451. #define elf_backend_final_write_processing \
  2452. mips_vxworks_final_write_processing
  2453. #undef elf_backend_additional_program_headers
  2454. #undef elf_backend_modify_segment_map
  2455. #undef elf_backend_symbol_processing
  2456. /* NOTE: elf_backend_rela_normal is not defined for MIPS. */
  2457. #undef bfd_elf32_get_synthetic_symtab
  2458. #include "elf32-target.h"