elfn32-mips.c 120 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748
  1. /* MIPS-specific support for 32-bit ELF
  2. Copyright (C) 1993-2015 Free Software Foundation, Inc.
  3. Most of the information added by Ian Lance Taylor, Cygnus Support,
  4. <ian@cygnus.com>.
  5. N32/64 ABI support added by Mark Mitchell, CodeSourcery, LLC.
  6. <mark@codesourcery.com>
  7. Traditional MIPS targets support added by Koundinya.K, Dansk Data
  8. Elektronik & Operations Research Group. <kk@ddeorg.soft.net>
  9. This file is part of BFD, the Binary File Descriptor library.
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 3 of the License, or
  13. (at your option) any later version.
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. GNU General Public License for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with this program; if not, write to the Free Software
  20. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  21. MA 02110-1301, USA. */
  22. /* This file handles MIPS ELF targets. SGI Irix 5 uses a slightly
  23. different MIPS ELF from other targets. This matters when linking.
  24. This file supports both, switching at runtime. */
  25. #include "sysdep.h"
  26. #include "bfd.h"
  27. #include "libbfd.h"
  28. #include "bfdlink.h"
  29. #include "genlink.h"
  30. #include "elf-bfd.h"
  31. #include "elfxx-mips.h"
  32. #include "elf/mips.h"
  33. /* Get the ECOFF swapping routines. */
  34. #include "coff/sym.h"
  35. #include "coff/symconst.h"
  36. #include "coff/internal.h"
  37. #include "coff/ecoff.h"
  38. #include "coff/mips.h"
  39. #define ECOFF_SIGNED_32
  40. #include "ecoffswap.h"
  41. static bfd_boolean mips_elf_assign_gp
  42. (bfd *, bfd_vma *);
  43. static bfd_reloc_status_type mips_elf_final_gp
  44. (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *);
  45. static bfd_reloc_status_type mips_elf_gprel16_reloc
  46. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  47. static bfd_reloc_status_type mips_elf_literal_reloc
  48. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  49. static bfd_reloc_status_type mips_elf_gprel32_reloc
  50. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  51. static bfd_reloc_status_type gprel32_with_gp
  52. (bfd *, asymbol *, arelent *, asection *, bfd_boolean, void *, bfd_vma);
  53. static bfd_reloc_status_type mips_elf_shift6_reloc
  54. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  55. static bfd_reloc_status_type mips16_gprel_reloc
  56. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  57. static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
  58. (bfd *, bfd_reloc_code_real_type);
  59. static reloc_howto_type *mips_elf_n32_rtype_to_howto
  60. (unsigned int, bfd_boolean);
  61. static void mips_info_to_howto_rel
  62. (bfd *, arelent *, Elf_Internal_Rela *);
  63. static void mips_info_to_howto_rela
  64. (bfd *, arelent *, Elf_Internal_Rela *);
  65. static bfd_boolean mips_elf_sym_is_global
  66. (bfd *, asymbol *);
  67. static bfd_boolean mips_elf_n32_object_p
  68. (bfd *);
  69. static bfd_boolean elf32_mips_grok_prstatus
  70. (bfd *, Elf_Internal_Note *);
  71. static bfd_boolean elf32_mips_grok_psinfo
  72. (bfd *, Elf_Internal_Note *);
  73. static irix_compat_t elf_n32_mips_irix_compat
  74. (bfd *);
  75. extern const bfd_target mips_elf32_n_be_vec;
  76. extern const bfd_target mips_elf32_n_le_vec;
  77. /* Nonzero if ABFD is using the N32 ABI. */
  78. #define ABI_N32_P(abfd) \
  79. ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
  80. /* Whether we are trying to be compatible with IRIX at all. */
  81. #define SGI_COMPAT(abfd) \
  82. (elf_n32_mips_irix_compat (abfd) != ict_none)
  83. /* The number of local .got entries we reserve. */
  84. #define MIPS_RESERVED_GOTNO (2)
  85. /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
  86. from smaller values. Start with zero, widen, *then* decrement. */
  87. #define MINUS_ONE (((bfd_vma)0) - 1)
  88. /* The relocation table used for SHT_REL sections. */
  89. static reloc_howto_type elf_mips_howto_table_rel[] =
  90. {
  91. /* No relocation. */
  92. HOWTO (R_MIPS_NONE, /* type */
  93. 0, /* rightshift */
  94. 3, /* size (0 = byte, 1 = short, 2 = long) */
  95. 0, /* bitsize */
  96. FALSE, /* pc_relative */
  97. 0, /* bitpos */
  98. complain_overflow_dont, /* complain_on_overflow */
  99. _bfd_mips_elf_generic_reloc, /* special_function */
  100. "R_MIPS_NONE", /* name */
  101. FALSE, /* partial_inplace */
  102. 0, /* src_mask */
  103. 0, /* dst_mask */
  104. FALSE), /* pcrel_offset */
  105. /* 16 bit relocation. */
  106. HOWTO (R_MIPS_16, /* type */
  107. 0, /* rightshift */
  108. 2, /* size (0 = byte, 1 = short, 2 = long) */
  109. 16, /* bitsize */
  110. FALSE, /* pc_relative */
  111. 0, /* bitpos */
  112. complain_overflow_signed, /* complain_on_overflow */
  113. _bfd_mips_elf_generic_reloc, /* special_function */
  114. "R_MIPS_16", /* name */
  115. TRUE, /* partial_inplace */
  116. 0x0000ffff, /* src_mask */
  117. 0x0000ffff, /* dst_mask */
  118. FALSE), /* pcrel_offset */
  119. /* 32 bit relocation. */
  120. HOWTO (R_MIPS_32, /* type */
  121. 0, /* rightshift */
  122. 2, /* size (0 = byte, 1 = short, 2 = long) */
  123. 32, /* bitsize */
  124. FALSE, /* pc_relative */
  125. 0, /* bitpos */
  126. complain_overflow_dont, /* complain_on_overflow */
  127. _bfd_mips_elf_generic_reloc, /* special_function */
  128. "R_MIPS_32", /* name */
  129. TRUE, /* partial_inplace */
  130. 0xffffffff, /* src_mask */
  131. 0xffffffff, /* dst_mask */
  132. FALSE), /* pcrel_offset */
  133. /* 32 bit symbol relative relocation. */
  134. HOWTO (R_MIPS_REL32, /* type */
  135. 0, /* rightshift */
  136. 2, /* size (0 = byte, 1 = short, 2 = long) */
  137. 32, /* bitsize */
  138. FALSE, /* pc_relative */
  139. 0, /* bitpos */
  140. complain_overflow_dont, /* complain_on_overflow */
  141. _bfd_mips_elf_generic_reloc, /* special_function */
  142. "R_MIPS_REL32", /* name */
  143. TRUE, /* partial_inplace */
  144. 0xffffffff, /* src_mask */
  145. 0xffffffff, /* dst_mask */
  146. FALSE), /* pcrel_offset */
  147. /* 26 bit jump address. */
  148. HOWTO (R_MIPS_26, /* type */
  149. 2, /* rightshift */
  150. 2, /* size (0 = byte, 1 = short, 2 = long) */
  151. 26, /* bitsize */
  152. FALSE, /* pc_relative */
  153. 0, /* bitpos */
  154. complain_overflow_dont, /* complain_on_overflow */
  155. /* This needs complex overflow
  156. detection, because the upper four
  157. bits must match the PC + 4. */
  158. _bfd_mips_elf_generic_reloc, /* special_function */
  159. "R_MIPS_26", /* name */
  160. TRUE, /* partial_inplace */
  161. 0x03ffffff, /* src_mask */
  162. 0x03ffffff, /* dst_mask */
  163. FALSE), /* pcrel_offset */
  164. /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL.
  165. However, the native IRIX6 tools use them, so we try our best. */
  166. /* High 16 bits of symbol value. */
  167. HOWTO (R_MIPS_HI16, /* type */
  168. 16, /* rightshift */
  169. 2, /* size (0 = byte, 1 = short, 2 = long) */
  170. 16, /* bitsize */
  171. FALSE, /* pc_relative */
  172. 0, /* bitpos */
  173. complain_overflow_dont, /* complain_on_overflow */
  174. _bfd_mips_elf_hi16_reloc, /* special_function */
  175. "R_MIPS_HI16", /* name */
  176. TRUE, /* partial_inplace */
  177. 0x0000ffff, /* src_mask */
  178. 0x0000ffff, /* dst_mask */
  179. FALSE), /* pcrel_offset */
  180. /* Low 16 bits of symbol value. */
  181. HOWTO (R_MIPS_LO16, /* type */
  182. 0, /* rightshift */
  183. 2, /* size (0 = byte, 1 = short, 2 = long) */
  184. 16, /* bitsize */
  185. FALSE, /* pc_relative */
  186. 0, /* bitpos */
  187. complain_overflow_dont, /* complain_on_overflow */
  188. _bfd_mips_elf_lo16_reloc, /* special_function */
  189. "R_MIPS_LO16", /* name */
  190. TRUE, /* partial_inplace */
  191. 0x0000ffff, /* src_mask */
  192. 0x0000ffff, /* dst_mask */
  193. FALSE), /* pcrel_offset */
  194. /* GP relative reference. */
  195. HOWTO (R_MIPS_GPREL16, /* type */
  196. 0, /* rightshift */
  197. 2, /* size (0 = byte, 1 = short, 2 = long) */
  198. 16, /* bitsize */
  199. FALSE, /* pc_relative */
  200. 0, /* bitpos */
  201. complain_overflow_signed, /* complain_on_overflow */
  202. mips_elf_gprel16_reloc, /* special_function */
  203. "R_MIPS_GPREL16", /* name */
  204. TRUE, /* partial_inplace */
  205. 0x0000ffff, /* src_mask */
  206. 0x0000ffff, /* dst_mask */
  207. FALSE), /* pcrel_offset */
  208. /* Reference to literal section. */
  209. HOWTO (R_MIPS_LITERAL, /* type */
  210. 0, /* rightshift */
  211. 2, /* size (0 = byte, 1 = short, 2 = long) */
  212. 16, /* bitsize */
  213. FALSE, /* pc_relative */
  214. 0, /* bitpos */
  215. complain_overflow_signed, /* complain_on_overflow */
  216. mips_elf_literal_reloc, /* special_function */
  217. "R_MIPS_LITERAL", /* name */
  218. TRUE, /* partial_inplace */
  219. 0x0000ffff, /* src_mask */
  220. 0x0000ffff, /* dst_mask */
  221. FALSE), /* pcrel_offset */
  222. /* Reference to global offset table. */
  223. HOWTO (R_MIPS_GOT16, /* type */
  224. 0, /* rightshift */
  225. 2, /* size (0 = byte, 1 = short, 2 = long) */
  226. 16, /* bitsize */
  227. FALSE, /* pc_relative */
  228. 0, /* bitpos */
  229. complain_overflow_signed, /* complain_on_overflow */
  230. _bfd_mips_elf_got16_reloc, /* special_function */
  231. "R_MIPS_GOT16", /* name */
  232. TRUE, /* partial_inplace */
  233. 0x0000ffff, /* src_mask */
  234. 0x0000ffff, /* dst_mask */
  235. FALSE), /* pcrel_offset */
  236. /* 16 bit PC relative reference. Note that the ABI document has a typo
  237. and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
  238. We do the right thing here. */
  239. HOWTO (R_MIPS_PC16, /* type */
  240. 2, /* rightshift */
  241. 2, /* size (0 = byte, 1 = short, 2 = long) */
  242. 16, /* bitsize */
  243. TRUE, /* pc_relative */
  244. 0, /* bitpos */
  245. complain_overflow_signed, /* complain_on_overflow */
  246. _bfd_mips_elf_generic_reloc, /* special_function */
  247. "R_MIPS_PC16", /* name */
  248. TRUE, /* partial_inplace */
  249. 0x0000ffff, /* src_mask */
  250. 0x0000ffff, /* dst_mask */
  251. TRUE), /* pcrel_offset */
  252. /* 16 bit call through global offset table. */
  253. HOWTO (R_MIPS_CALL16, /* type */
  254. 0, /* rightshift */
  255. 2, /* size (0 = byte, 1 = short, 2 = long) */
  256. 16, /* bitsize */
  257. FALSE, /* pc_relative */
  258. 0, /* bitpos */
  259. complain_overflow_signed, /* complain_on_overflow */
  260. _bfd_mips_elf_generic_reloc, /* special_function */
  261. "R_MIPS_CALL16", /* name */
  262. TRUE, /* partial_inplace */
  263. 0x0000ffff, /* src_mask */
  264. 0x0000ffff, /* dst_mask */
  265. FALSE), /* pcrel_offset */
  266. /* 32 bit GP relative reference. */
  267. HOWTO (R_MIPS_GPREL32, /* type */
  268. 0, /* rightshift */
  269. 2, /* size (0 = byte, 1 = short, 2 = long) */
  270. 32, /* bitsize */
  271. FALSE, /* pc_relative */
  272. 0, /* bitpos */
  273. complain_overflow_dont, /* complain_on_overflow */
  274. mips_elf_gprel32_reloc, /* special_function */
  275. "R_MIPS_GPREL32", /* name */
  276. TRUE, /* partial_inplace */
  277. 0xffffffff, /* src_mask */
  278. 0xffffffff, /* dst_mask */
  279. FALSE), /* pcrel_offset */
  280. /* The remaining relocs are defined on Irix 5, although they are
  281. not defined by the ABI. */
  282. EMPTY_HOWTO (13),
  283. EMPTY_HOWTO (14),
  284. EMPTY_HOWTO (15),
  285. /* A 5 bit shift field. */
  286. HOWTO (R_MIPS_SHIFT5, /* type */
  287. 0, /* rightshift */
  288. 2, /* size (0 = byte, 1 = short, 2 = long) */
  289. 5, /* bitsize */
  290. FALSE, /* pc_relative */
  291. 6, /* bitpos */
  292. complain_overflow_bitfield, /* complain_on_overflow */
  293. _bfd_mips_elf_generic_reloc, /* special_function */
  294. "R_MIPS_SHIFT5", /* name */
  295. TRUE, /* partial_inplace */
  296. 0x000007c0, /* src_mask */
  297. 0x000007c0, /* dst_mask */
  298. FALSE), /* pcrel_offset */
  299. /* A 6 bit shift field. */
  300. HOWTO (R_MIPS_SHIFT6, /* type */
  301. 0, /* rightshift */
  302. 2, /* size (0 = byte, 1 = short, 2 = long) */
  303. 6, /* bitsize */
  304. FALSE, /* pc_relative */
  305. 6, /* bitpos */
  306. complain_overflow_bitfield, /* complain_on_overflow */
  307. mips_elf_shift6_reloc, /* special_function */
  308. "R_MIPS_SHIFT6", /* name */
  309. TRUE, /* partial_inplace */
  310. 0x000007c4, /* src_mask */
  311. 0x000007c4, /* dst_mask */
  312. FALSE), /* pcrel_offset */
  313. /* A 64 bit relocation. */
  314. HOWTO (R_MIPS_64, /* type */
  315. 0, /* rightshift */
  316. 4, /* size (0 = byte, 1 = short, 2 = long) */
  317. 64, /* bitsize */
  318. FALSE, /* pc_relative */
  319. 0, /* bitpos */
  320. complain_overflow_dont, /* complain_on_overflow */
  321. _bfd_mips_elf_generic_reloc, /* special_function */
  322. "R_MIPS_64", /* name */
  323. TRUE, /* partial_inplace */
  324. MINUS_ONE, /* src_mask */
  325. MINUS_ONE, /* dst_mask */
  326. FALSE), /* pcrel_offset */
  327. /* Displacement in the global offset table. */
  328. HOWTO (R_MIPS_GOT_DISP, /* type */
  329. 0, /* rightshift */
  330. 2, /* size (0 = byte, 1 = short, 2 = long) */
  331. 16, /* bitsize */
  332. FALSE, /* pc_relative */
  333. 0, /* bitpos */
  334. complain_overflow_signed, /* complain_on_overflow */
  335. _bfd_mips_elf_generic_reloc, /* special_function */
  336. "R_MIPS_GOT_DISP", /* name */
  337. TRUE, /* partial_inplace */
  338. 0x0000ffff, /* src_mask */
  339. 0x0000ffff, /* dst_mask */
  340. FALSE), /* pcrel_offset */
  341. /* Displacement to page pointer in the global offset table. */
  342. HOWTO (R_MIPS_GOT_PAGE, /* type */
  343. 0, /* rightshift */
  344. 2, /* size (0 = byte, 1 = short, 2 = long) */
  345. 16, /* bitsize */
  346. FALSE, /* pc_relative */
  347. 0, /* bitpos */
  348. complain_overflow_signed, /* complain_on_overflow */
  349. _bfd_mips_elf_generic_reloc, /* special_function */
  350. "R_MIPS_GOT_PAGE", /* name */
  351. TRUE, /* partial_inplace */
  352. 0x0000ffff, /* src_mask */
  353. 0x0000ffff, /* dst_mask */
  354. FALSE), /* pcrel_offset */
  355. /* Offset from page pointer in the global offset table. */
  356. HOWTO (R_MIPS_GOT_OFST, /* type */
  357. 0, /* rightshift */
  358. 2, /* size (0 = byte, 1 = short, 2 = long) */
  359. 16, /* bitsize */
  360. FALSE, /* pc_relative */
  361. 0, /* bitpos */
  362. complain_overflow_signed, /* complain_on_overflow */
  363. _bfd_mips_elf_generic_reloc, /* special_function */
  364. "R_MIPS_GOT_OFST", /* name */
  365. TRUE, /* partial_inplace */
  366. 0x0000ffff, /* src_mask */
  367. 0x0000ffff, /* dst_mask */
  368. FALSE), /* pcrel_offset */
  369. /* High 16 bits of displacement in global offset table. */
  370. HOWTO (R_MIPS_GOT_HI16, /* type */
  371. 0, /* rightshift */
  372. 2, /* size (0 = byte, 1 = short, 2 = long) */
  373. 16, /* bitsize */
  374. FALSE, /* pc_relative */
  375. 0, /* bitpos */
  376. complain_overflow_dont, /* complain_on_overflow */
  377. _bfd_mips_elf_generic_reloc, /* special_function */
  378. "R_MIPS_GOT_HI16", /* name */
  379. TRUE, /* partial_inplace */
  380. 0x0000ffff, /* src_mask */
  381. 0x0000ffff, /* dst_mask */
  382. FALSE), /* pcrel_offset */
  383. /* Low 16 bits of displacement in global offset table. */
  384. HOWTO (R_MIPS_GOT_LO16, /* type */
  385. 0, /* rightshift */
  386. 2, /* size (0 = byte, 1 = short, 2 = long) */
  387. 16, /* bitsize */
  388. FALSE, /* pc_relative */
  389. 0, /* bitpos */
  390. complain_overflow_dont, /* complain_on_overflow */
  391. _bfd_mips_elf_generic_reloc, /* special_function */
  392. "R_MIPS_GOT_LO16", /* name */
  393. TRUE, /* partial_inplace */
  394. 0x0000ffff, /* src_mask */
  395. 0x0000ffff, /* dst_mask */
  396. FALSE), /* pcrel_offset */
  397. /* 64 bit subtraction. */
  398. HOWTO (R_MIPS_SUB, /* type */
  399. 0, /* rightshift */
  400. 4, /* size (0 = byte, 1 = short, 2 = long) */
  401. 64, /* bitsize */
  402. FALSE, /* pc_relative */
  403. 0, /* bitpos */
  404. complain_overflow_dont, /* complain_on_overflow */
  405. _bfd_mips_elf_generic_reloc, /* special_function */
  406. "R_MIPS_SUB", /* name */
  407. TRUE, /* partial_inplace */
  408. MINUS_ONE, /* src_mask */
  409. MINUS_ONE, /* dst_mask */
  410. FALSE), /* pcrel_offset */
  411. /* Insert the addend as an instruction. */
  412. /* FIXME: Not handled correctly. */
  413. HOWTO (R_MIPS_INSERT_A, /* type */
  414. 0, /* rightshift */
  415. 2, /* size (0 = byte, 1 = short, 2 = long) */
  416. 32, /* bitsize */
  417. FALSE, /* pc_relative */
  418. 0, /* bitpos */
  419. complain_overflow_dont, /* complain_on_overflow */
  420. _bfd_mips_elf_generic_reloc, /* special_function */
  421. "R_MIPS_INSERT_A", /* name */
  422. TRUE, /* partial_inplace */
  423. 0xffffffff, /* src_mask */
  424. 0xffffffff, /* dst_mask */
  425. FALSE), /* pcrel_offset */
  426. /* Insert the addend as an instruction, and change all relocations
  427. to refer to the old instruction at the address. */
  428. /* FIXME: Not handled correctly. */
  429. HOWTO (R_MIPS_INSERT_B, /* type */
  430. 0, /* rightshift */
  431. 2, /* size (0 = byte, 1 = short, 2 = long) */
  432. 32, /* 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_INSERT_B", /* name */
  438. TRUE, /* partial_inplace */
  439. 0xffffffff, /* src_mask */
  440. 0xffffffff, /* dst_mask */
  441. FALSE), /* pcrel_offset */
  442. /* Delete a 32 bit instruction. */
  443. /* FIXME: Not handled correctly. */
  444. HOWTO (R_MIPS_DELETE, /* type */
  445. 0, /* rightshift */
  446. 2, /* size (0 = byte, 1 = short, 2 = long) */
  447. 32, /* bitsize */
  448. FALSE, /* pc_relative */
  449. 0, /* bitpos */
  450. complain_overflow_dont, /* complain_on_overflow */
  451. _bfd_mips_elf_generic_reloc, /* special_function */
  452. "R_MIPS_DELETE", /* name */
  453. TRUE, /* partial_inplace */
  454. 0xffffffff, /* src_mask */
  455. 0xffffffff, /* dst_mask */
  456. FALSE), /* pcrel_offset */
  457. /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations.
  458. We don't, because
  459. a) It means building the addend from a R_MIPS_HIGHEST/R_MIPS_HIGHER/
  460. R_MIPS_HI16/R_MIPS_LO16 sequence with varying ordering, using
  461. fallable heuristics.
  462. b) No other NewABI toolchain actually emits such relocations. */
  463. EMPTY_HOWTO (R_MIPS_HIGHER),
  464. EMPTY_HOWTO (R_MIPS_HIGHEST),
  465. /* High 16 bits of displacement in global offset table. */
  466. HOWTO (R_MIPS_CALL_HI16, /* type */
  467. 0, /* rightshift */
  468. 2, /* size (0 = byte, 1 = short, 2 = long) */
  469. 16, /* bitsize */
  470. FALSE, /* pc_relative */
  471. 0, /* bitpos */
  472. complain_overflow_dont, /* complain_on_overflow */
  473. _bfd_mips_elf_generic_reloc, /* special_function */
  474. "R_MIPS_CALL_HI16", /* name */
  475. TRUE, /* partial_inplace */
  476. 0x0000ffff, /* src_mask */
  477. 0x0000ffff, /* dst_mask */
  478. FALSE), /* pcrel_offset */
  479. /* Low 16 bits of displacement in global offset table. */
  480. HOWTO (R_MIPS_CALL_LO16, /* type */
  481. 0, /* rightshift */
  482. 2, /* size (0 = byte, 1 = short, 2 = long) */
  483. 16, /* bitsize */
  484. FALSE, /* pc_relative */
  485. 0, /* bitpos */
  486. complain_overflow_dont, /* complain_on_overflow */
  487. _bfd_mips_elf_generic_reloc, /* special_function */
  488. "R_MIPS_CALL_LO16", /* name */
  489. TRUE, /* partial_inplace */
  490. 0x0000ffff, /* src_mask */
  491. 0x0000ffff, /* dst_mask */
  492. FALSE), /* pcrel_offset */
  493. /* Section displacement. */
  494. HOWTO (R_MIPS_SCN_DISP, /* type */
  495. 0, /* rightshift */
  496. 2, /* size (0 = byte, 1 = short, 2 = long) */
  497. 32, /* bitsize */
  498. FALSE, /* pc_relative */
  499. 0, /* bitpos */
  500. complain_overflow_dont, /* complain_on_overflow */
  501. _bfd_mips_elf_generic_reloc, /* special_function */
  502. "R_MIPS_SCN_DISP", /* name */
  503. TRUE, /* partial_inplace */
  504. 0xffffffff, /* src_mask */
  505. 0xffffffff, /* dst_mask */
  506. FALSE), /* pcrel_offset */
  507. HOWTO (R_MIPS_REL16, /* type */
  508. 0, /* rightshift */
  509. 1, /* size (0 = byte, 1 = short, 2 = long) */
  510. 16, /* bitsize */
  511. FALSE, /* pc_relative */
  512. 0, /* bitpos */
  513. complain_overflow_signed, /* complain_on_overflow */
  514. _bfd_mips_elf_generic_reloc, /* special_function */
  515. "R_MIPS_REL16", /* name */
  516. TRUE, /* partial_inplace */
  517. 0xffff, /* src_mask */
  518. 0xffff, /* dst_mask */
  519. FALSE), /* pcrel_offset */
  520. /* These two are obsolete. */
  521. EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
  522. EMPTY_HOWTO (R_MIPS_PJUMP),
  523. /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
  524. It must be used for multigot GOT's (and only there). */
  525. HOWTO (R_MIPS_RELGOT, /* type */
  526. 0, /* rightshift */
  527. 2, /* size (0 = byte, 1 = short, 2 = long) */
  528. 32, /* bitsize */
  529. FALSE, /* pc_relative */
  530. 0, /* bitpos */
  531. complain_overflow_dont, /* complain_on_overflow */
  532. _bfd_mips_elf_generic_reloc, /* special_function */
  533. "R_MIPS_RELGOT", /* name */
  534. TRUE, /* partial_inplace */
  535. 0xffffffff, /* src_mask */
  536. 0xffffffff, /* dst_mask */
  537. FALSE), /* pcrel_offset */
  538. /* Protected jump conversion. This is an optimization hint. No
  539. relocation is required for correctness. */
  540. HOWTO (R_MIPS_JALR, /* type */
  541. 0, /* rightshift */
  542. 2, /* size (0 = byte, 1 = short, 2 = long) */
  543. 32, /* bitsize */
  544. FALSE, /* pc_relative */
  545. 0, /* bitpos */
  546. complain_overflow_dont, /* complain_on_overflow */
  547. _bfd_mips_elf_generic_reloc, /* special_function */
  548. "R_MIPS_JALR", /* name */
  549. FALSE, /* partial_inplace */
  550. 0x00000000, /* src_mask */
  551. 0x00000000, /* dst_mask */
  552. FALSE), /* pcrel_offset */
  553. /* TLS GD/LD dynamic relocations. */
  554. HOWTO (R_MIPS_TLS_DTPMOD32, /* type */
  555. 0, /* rightshift */
  556. 2, /* size (0 = byte, 1 = short, 2 = long) */
  557. 32, /* bitsize */
  558. FALSE, /* pc_relative */
  559. 0, /* bitpos */
  560. complain_overflow_dont, /* complain_on_overflow */
  561. _bfd_mips_elf_generic_reloc, /* special_function */
  562. "R_MIPS_TLS_DTPMOD32", /* name */
  563. TRUE, /* partial_inplace */
  564. 0xffffffff, /* src_mask */
  565. 0xffffffff, /* dst_mask */
  566. FALSE), /* pcrel_offset */
  567. HOWTO (R_MIPS_TLS_DTPREL32, /* type */
  568. 0, /* rightshift */
  569. 2, /* size (0 = byte, 1 = short, 2 = long) */
  570. 32, /* bitsize */
  571. FALSE, /* pc_relative */
  572. 0, /* bitpos */
  573. complain_overflow_dont, /* complain_on_overflow */
  574. _bfd_mips_elf_generic_reloc, /* special_function */
  575. "R_MIPS_TLS_DTPREL32", /* name */
  576. TRUE, /* partial_inplace */
  577. 0xffffffff, /* src_mask */
  578. 0xffffffff, /* dst_mask */
  579. FALSE), /* pcrel_offset */
  580. EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
  581. EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
  582. /* TLS general dynamic variable reference. */
  583. HOWTO (R_MIPS_TLS_GD, /* type */
  584. 0, /* rightshift */
  585. 2, /* size (0 = byte, 1 = short, 2 = long) */
  586. 16, /* bitsize */
  587. FALSE, /* pc_relative */
  588. 0, /* bitpos */
  589. complain_overflow_signed, /* complain_on_overflow */
  590. _bfd_mips_elf_generic_reloc, /* special_function */
  591. "R_MIPS_TLS_GD", /* name */
  592. TRUE, /* partial_inplace */
  593. 0x0000ffff, /* src_mask */
  594. 0x0000ffff, /* dst_mask */
  595. FALSE), /* pcrel_offset */
  596. /* TLS local dynamic variable reference. */
  597. HOWTO (R_MIPS_TLS_LDM, /* type */
  598. 0, /* rightshift */
  599. 2, /* size (0 = byte, 1 = short, 2 = long) */
  600. 16, /* bitsize */
  601. FALSE, /* pc_relative */
  602. 0, /* bitpos */
  603. complain_overflow_signed, /* complain_on_overflow */
  604. _bfd_mips_elf_generic_reloc, /* special_function */
  605. "R_MIPS_TLS_LDM", /* name */
  606. TRUE, /* partial_inplace */
  607. 0x0000ffff, /* src_mask */
  608. 0x0000ffff, /* dst_mask */
  609. FALSE), /* pcrel_offset */
  610. /* TLS local dynamic offset. */
  611. HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */
  612. 0, /* rightshift */
  613. 2, /* size (0 = byte, 1 = short, 2 = long) */
  614. 16, /* bitsize */
  615. FALSE, /* pc_relative */
  616. 0, /* bitpos */
  617. complain_overflow_signed, /* complain_on_overflow */
  618. _bfd_mips_elf_generic_reloc, /* special_function */
  619. "R_MIPS_TLS_DTPREL_HI16", /* name */
  620. TRUE, /* partial_inplace */
  621. 0x0000ffff, /* src_mask */
  622. 0x0000ffff, /* dst_mask */
  623. FALSE), /* pcrel_offset */
  624. /* TLS local dynamic offset. */
  625. HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */
  626. 0, /* rightshift */
  627. 2, /* size (0 = byte, 1 = short, 2 = long) */
  628. 16, /* bitsize */
  629. FALSE, /* pc_relative */
  630. 0, /* bitpos */
  631. complain_overflow_signed, /* complain_on_overflow */
  632. _bfd_mips_elf_generic_reloc, /* special_function */
  633. "R_MIPS_TLS_DTPREL_LO16", /* name */
  634. TRUE, /* partial_inplace */
  635. 0x0000ffff, /* src_mask */
  636. 0x0000ffff, /* dst_mask */
  637. FALSE), /* pcrel_offset */
  638. /* TLS thread pointer offset. */
  639. HOWTO (R_MIPS_TLS_GOTTPREL, /* type */
  640. 0, /* rightshift */
  641. 2, /* size (0 = byte, 1 = short, 2 = long) */
  642. 16, /* bitsize */
  643. FALSE, /* pc_relative */
  644. 0, /* bitpos */
  645. complain_overflow_signed, /* complain_on_overflow */
  646. _bfd_mips_elf_generic_reloc, /* special_function */
  647. "R_MIPS_TLS_GOTTPREL", /* name */
  648. TRUE, /* partial_inplace */
  649. 0x0000ffff, /* src_mask */
  650. 0x0000ffff, /* dst_mask */
  651. FALSE), /* pcrel_offset */
  652. /* TLS IE dynamic relocations. */
  653. HOWTO (R_MIPS_TLS_TPREL32, /* type */
  654. 0, /* rightshift */
  655. 2, /* size (0 = byte, 1 = short, 2 = long) */
  656. 32, /* bitsize */
  657. FALSE, /* pc_relative */
  658. 0, /* bitpos */
  659. complain_overflow_dont, /* complain_on_overflow */
  660. _bfd_mips_elf_generic_reloc, /* special_function */
  661. "R_MIPS_TLS_TPREL32", /* name */
  662. TRUE, /* partial_inplace */
  663. 0xffffffff, /* src_mask */
  664. 0xffffffff, /* dst_mask */
  665. FALSE), /* pcrel_offset */
  666. EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
  667. /* TLS thread pointer offset. */
  668. HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */
  669. 0, /* rightshift */
  670. 2, /* size (0 = byte, 1 = short, 2 = long) */
  671. 16, /* bitsize */
  672. FALSE, /* pc_relative */
  673. 0, /* bitpos */
  674. complain_overflow_signed, /* complain_on_overflow */
  675. _bfd_mips_elf_generic_reloc, /* special_function */
  676. "R_MIPS_TLS_TPREL_HI16", /* name */
  677. TRUE, /* partial_inplace */
  678. 0x0000ffff, /* src_mask */
  679. 0x0000ffff, /* dst_mask */
  680. FALSE), /* pcrel_offset */
  681. /* TLS thread pointer offset. */
  682. HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */
  683. 0, /* rightshift */
  684. 2, /* size (0 = byte, 1 = short, 2 = long) */
  685. 16, /* bitsize */
  686. FALSE, /* pc_relative */
  687. 0, /* bitpos */
  688. complain_overflow_signed, /* complain_on_overflow */
  689. _bfd_mips_elf_generic_reloc, /* special_function */
  690. "R_MIPS_TLS_TPREL_LO16", /* name */
  691. TRUE, /* partial_inplace */
  692. 0x0000ffff, /* src_mask */
  693. 0x0000ffff, /* dst_mask */
  694. FALSE), /* pcrel_offset */
  695. /* 32 bit relocation with no addend. */
  696. HOWTO (R_MIPS_GLOB_DAT, /* type */
  697. 0, /* rightshift */
  698. 2, /* size (0 = byte, 1 = short, 2 = long) */
  699. 32, /* bitsize */
  700. FALSE, /* pc_relative */
  701. 0, /* bitpos */
  702. complain_overflow_dont, /* complain_on_overflow */
  703. _bfd_mips_elf_generic_reloc, /* special_function */
  704. "R_MIPS_GLOB_DAT", /* name */
  705. FALSE, /* partial_inplace */
  706. 0x0, /* src_mask */
  707. 0xffffffff, /* dst_mask */
  708. FALSE), /* pcrel_offset */
  709. EMPTY_HOWTO (52),
  710. EMPTY_HOWTO (53),
  711. EMPTY_HOWTO (54),
  712. EMPTY_HOWTO (55),
  713. EMPTY_HOWTO (56),
  714. EMPTY_HOWTO (57),
  715. EMPTY_HOWTO (58),
  716. EMPTY_HOWTO (59),
  717. HOWTO (R_MIPS_PC21_S2, /* type */
  718. 2, /* rightshift */
  719. 2, /* size (0 = byte, 1 = short, 2 = long) */
  720. 21, /* bitsize */
  721. TRUE, /* pc_relative */
  722. 0, /* bitpos */
  723. complain_overflow_signed, /* complain_on_overflow */
  724. _bfd_mips_elf_generic_reloc, /* special_function */
  725. "R_MIPS_PC21_S2", /* name */
  726. TRUE, /* partial_inplace */
  727. 0x001fffff, /* src_mask */
  728. 0x001fffff, /* dst_mask */
  729. TRUE), /* pcrel_offset */
  730. HOWTO (R_MIPS_PC26_S2, /* type */
  731. 2, /* rightshift */
  732. 2, /* size (0 = byte, 1 = short, 2 = long) */
  733. 26, /* bitsize */
  734. TRUE, /* pc_relative */
  735. 0, /* bitpos */
  736. complain_overflow_signed, /* complain_on_overflow */
  737. _bfd_mips_elf_generic_reloc, /* special_function */
  738. "R_MIPS_PC26_S2", /* name */
  739. TRUE, /* partial_inplace */
  740. 0x03ffffff, /* src_mask */
  741. 0x03ffffff, /* dst_mask */
  742. TRUE), /* pcrel_offset */
  743. HOWTO (R_MIPS_PC18_S3, /* type */
  744. 3, /* rightshift */
  745. 2, /* size (0 = byte, 1 = short, 2 = long) */
  746. 18, /* bitsize */
  747. TRUE, /* pc_relative */
  748. 0, /* bitpos */
  749. complain_overflow_signed, /* complain_on_overflow */
  750. _bfd_mips_elf_generic_reloc, /* special_function */
  751. "R_MIPS_PC18_S3", /* name */
  752. TRUE, /* partial_inplace */
  753. 0x0003ffff, /* src_mask */
  754. 0x0003ffff, /* dst_mask */
  755. TRUE), /* pcrel_offset */
  756. HOWTO (R_MIPS_PC19_S2, /* type */
  757. 2, /* rightshift */
  758. 2, /* size (0 = byte, 1 = short, 2 = long) */
  759. 19, /* bitsize */
  760. TRUE, /* pc_relative */
  761. 0, /* bitpos */
  762. complain_overflow_signed, /* complain_on_overflow */
  763. _bfd_mips_elf_generic_reloc, /* special_function */
  764. "R_MIPS_PC19_S2", /* name */
  765. TRUE, /* partial_inplace */
  766. 0x0007ffff, /* src_mask */
  767. 0x0007ffff, /* dst_mask */
  768. TRUE), /* pcrel_offset */
  769. HOWTO (R_MIPS_PCHI16, /* type */
  770. 16, /* rightshift */
  771. 2, /* size (0 = byte, 1 = short, 2 = long) */
  772. 16, /* bitsize */
  773. TRUE, /* pc_relative */
  774. 0, /* bitpos */
  775. complain_overflow_signed, /* complain_on_overflow */
  776. _bfd_mips_elf_generic_reloc, /* special_function */
  777. "R_MIPS_PCHI16", /* name */
  778. TRUE, /* partial_inplace */
  779. 0x0000ffff, /* src_mask */
  780. 0x0000ffff, /* dst_mask */
  781. TRUE), /* pcrel_offset */
  782. HOWTO (R_MIPS_PCLO16, /* type */
  783. 0, /* rightshift */
  784. 2, /* size (0 = byte, 1 = short, 2 = long) */
  785. 16, /* bitsize */
  786. TRUE, /* pc_relative */
  787. 0, /* bitpos */
  788. complain_overflow_dont, /* complain_on_overflow */
  789. _bfd_mips_elf_generic_reloc, /* special_function */
  790. "R_MIPS_PCLO16", /* name */
  791. TRUE, /* partial_inplace */
  792. 0x0000ffff, /* src_mask */
  793. 0x0000ffff, /* dst_mask */
  794. TRUE), /* pcrel_offset */
  795. };
  796. /* The relocation table used for SHT_RELA sections. */
  797. static reloc_howto_type elf_mips_howto_table_rela[] =
  798. {
  799. /* No relocation. */
  800. HOWTO (R_MIPS_NONE, /* type */
  801. 0, /* rightshift */
  802. 0, /* size (0 = byte, 1 = short, 2 = long) */
  803. 0, /* bitsize */
  804. FALSE, /* pc_relative */
  805. 0, /* bitpos */
  806. complain_overflow_dont, /* complain_on_overflow */
  807. _bfd_mips_elf_generic_reloc, /* special_function */
  808. "R_MIPS_NONE", /* name */
  809. FALSE, /* partial_inplace */
  810. 0, /* src_mask */
  811. 0, /* dst_mask */
  812. FALSE), /* pcrel_offset */
  813. /* 16 bit relocation. */
  814. HOWTO (R_MIPS_16, /* type */
  815. 0, /* rightshift */
  816. 2, /* size (0 = byte, 1 = short, 2 = long) */
  817. 16, /* bitsize */
  818. FALSE, /* pc_relative */
  819. 0, /* bitpos */
  820. complain_overflow_signed, /* complain_on_overflow */
  821. _bfd_mips_elf_generic_reloc, /* special_function */
  822. "R_MIPS_16", /* name */
  823. FALSE, /* partial_inplace */
  824. 0, /* src_mask */
  825. 0x0000, /* dst_mask */
  826. FALSE), /* pcrel_offset */
  827. /* 32 bit relocation. */
  828. HOWTO (R_MIPS_32, /* type */
  829. 0, /* rightshift */
  830. 2, /* size (0 = byte, 1 = short, 2 = long) */
  831. 32, /* bitsize */
  832. FALSE, /* pc_relative */
  833. 0, /* bitpos */
  834. complain_overflow_dont, /* complain_on_overflow */
  835. _bfd_mips_elf_generic_reloc, /* special_function */
  836. "R_MIPS_32", /* name */
  837. FALSE, /* partial_inplace */
  838. 0, /* src_mask */
  839. 0xffffffff, /* dst_mask */
  840. FALSE), /* pcrel_offset */
  841. /* 32 bit symbol relative relocation. */
  842. HOWTO (R_MIPS_REL32, /* type */
  843. 0, /* rightshift */
  844. 2, /* size (0 = byte, 1 = short, 2 = long) */
  845. 32, /* bitsize */
  846. FALSE, /* pc_relative */
  847. 0, /* bitpos */
  848. complain_overflow_dont, /* complain_on_overflow */
  849. _bfd_mips_elf_generic_reloc, /* special_function */
  850. "R_MIPS_REL32", /* name */
  851. FALSE, /* partial_inplace */
  852. 0, /* src_mask */
  853. 0xffffffff, /* dst_mask */
  854. FALSE), /* pcrel_offset */
  855. /* 26 bit jump address. */
  856. HOWTO (R_MIPS_26, /* type */
  857. 2, /* rightshift */
  858. 2, /* size (0 = byte, 1 = short, 2 = long) */
  859. 26, /* bitsize */
  860. FALSE, /* pc_relative */
  861. 0, /* bitpos */
  862. complain_overflow_dont, /* complain_on_overflow */
  863. /* This needs complex overflow
  864. detection, because the upper 36
  865. bits must match the PC + 4. */
  866. _bfd_mips_elf_generic_reloc, /* special_function */
  867. "R_MIPS_26", /* name */
  868. FALSE, /* partial_inplace */
  869. 0, /* src_mask */
  870. 0x03ffffff, /* dst_mask */
  871. FALSE), /* pcrel_offset */
  872. /* High 16 bits of symbol value. */
  873. HOWTO (R_MIPS_HI16, /* type */
  874. 0, /* rightshift */
  875. 2, /* size (0 = byte, 1 = short, 2 = long) */
  876. 16, /* bitsize */
  877. FALSE, /* pc_relative */
  878. 0, /* bitpos */
  879. complain_overflow_dont, /* complain_on_overflow */
  880. _bfd_mips_elf_generic_reloc, /* special_function */
  881. "R_MIPS_HI16", /* name */
  882. FALSE, /* partial_inplace */
  883. 0, /* src_mask */
  884. 0x0000ffff, /* dst_mask */
  885. FALSE), /* pcrel_offset */
  886. /* Low 16 bits of symbol value. */
  887. HOWTO (R_MIPS_LO16, /* type */
  888. 0, /* rightshift */
  889. 2, /* size (0 = byte, 1 = short, 2 = long) */
  890. 16, /* bitsize */
  891. FALSE, /* pc_relative */
  892. 0, /* bitpos */
  893. complain_overflow_dont, /* complain_on_overflow */
  894. _bfd_mips_elf_generic_reloc, /* special_function */
  895. "R_MIPS_LO16", /* name */
  896. FALSE, /* partial_inplace */
  897. 0, /* src_mask */
  898. 0x0000ffff, /* dst_mask */
  899. FALSE), /* pcrel_offset */
  900. /* GP relative reference. */
  901. HOWTO (R_MIPS_GPREL16, /* type */
  902. 0, /* rightshift */
  903. 2, /* size (0 = byte, 1 = short, 2 = long) */
  904. 16, /* bitsize */
  905. FALSE, /* pc_relative */
  906. 0, /* bitpos */
  907. complain_overflow_signed, /* complain_on_overflow */
  908. mips_elf_gprel16_reloc, /* special_function */
  909. "R_MIPS_GPREL16", /* name */
  910. FALSE, /* partial_inplace */
  911. 0, /* src_mask */
  912. 0x0000ffff, /* dst_mask */
  913. FALSE), /* pcrel_offset */
  914. /* Reference to literal section. */
  915. HOWTO (R_MIPS_LITERAL, /* type */
  916. 0, /* rightshift */
  917. 2, /* size (0 = byte, 1 = short, 2 = long) */
  918. 16, /* bitsize */
  919. FALSE, /* pc_relative */
  920. 0, /* bitpos */
  921. complain_overflow_signed, /* complain_on_overflow */
  922. mips_elf_literal_reloc, /* special_function */
  923. "R_MIPS_LITERAL", /* name */
  924. FALSE, /* partial_inplace */
  925. 0, /* src_mask */
  926. 0x0000ffff, /* dst_mask */
  927. FALSE), /* pcrel_offset */
  928. /* Reference to global offset table. */
  929. HOWTO (R_MIPS_GOT16, /* type */
  930. 0, /* rightshift */
  931. 2, /* size (0 = byte, 1 = short, 2 = long) */
  932. 16, /* bitsize */
  933. FALSE, /* pc_relative */
  934. 0, /* bitpos */
  935. complain_overflow_signed, /* complain_on_overflow */
  936. _bfd_mips_elf_generic_reloc, /* special_function */
  937. "R_MIPS_GOT16", /* name */
  938. FALSE, /* partial_inplace */
  939. 0, /* src_mask */
  940. 0x0000ffff, /* dst_mask */
  941. FALSE), /* pcrel_offset */
  942. /* 16 bit PC relative reference. Note that the ABI document has a typo
  943. and claims R_MIPS_PC16 to be not rightshifted, rendering it useless.
  944. We do the right thing here. */
  945. HOWTO (R_MIPS_PC16, /* type */
  946. 2, /* rightshift */
  947. 2, /* size (0 = byte, 1 = short, 2 = long) */
  948. 16, /* bitsize */
  949. TRUE, /* pc_relative */
  950. 0, /* bitpos */
  951. complain_overflow_signed, /* complain_on_overflow */
  952. _bfd_mips_elf_generic_reloc, /* special_function */
  953. "R_MIPS_PC16", /* name */
  954. FALSE, /* partial_inplace */
  955. 0, /* src_mask */
  956. 0x0000ffff, /* dst_mask */
  957. TRUE), /* pcrel_offset */
  958. /* 16 bit call through global offset table. */
  959. HOWTO (R_MIPS_CALL16, /* type */
  960. 0, /* rightshift */
  961. 2, /* size (0 = byte, 1 = short, 2 = long) */
  962. 16, /* bitsize */
  963. FALSE, /* pc_relative */
  964. 0, /* bitpos */
  965. complain_overflow_signed, /* complain_on_overflow */
  966. _bfd_mips_elf_generic_reloc, /* special_function */
  967. "R_MIPS_CALL16", /* name */
  968. FALSE, /* partial_inplace */
  969. 0, /* src_mask */
  970. 0x0000ffff, /* dst_mask */
  971. FALSE), /* pcrel_offset */
  972. /* 32 bit GP relative reference. */
  973. HOWTO (R_MIPS_GPREL32, /* type */
  974. 0, /* rightshift */
  975. 2, /* size (0 = byte, 1 = short, 2 = long) */
  976. 32, /* bitsize */
  977. FALSE, /* pc_relative */
  978. 0, /* bitpos */
  979. complain_overflow_dont, /* complain_on_overflow */
  980. mips_elf_gprel32_reloc, /* special_function */
  981. "R_MIPS_GPREL32", /* name */
  982. FALSE, /* partial_inplace */
  983. 0, /* src_mask */
  984. 0xffffffff, /* dst_mask */
  985. FALSE), /* pcrel_offset */
  986. EMPTY_HOWTO (13),
  987. EMPTY_HOWTO (14),
  988. EMPTY_HOWTO (15),
  989. /* A 5 bit shift field. */
  990. HOWTO (R_MIPS_SHIFT5, /* type */
  991. 0, /* rightshift */
  992. 2, /* size (0 = byte, 1 = short, 2 = long) */
  993. 5, /* bitsize */
  994. FALSE, /* pc_relative */
  995. 6, /* bitpos */
  996. complain_overflow_bitfield, /* complain_on_overflow */
  997. _bfd_mips_elf_generic_reloc, /* special_function */
  998. "R_MIPS_SHIFT5", /* name */
  999. FALSE, /* partial_inplace */
  1000. 0, /* src_mask */
  1001. 0x000007c0, /* dst_mask */
  1002. FALSE), /* pcrel_offset */
  1003. /* A 6 bit shift field. */
  1004. HOWTO (R_MIPS_SHIFT6, /* type */
  1005. 0, /* rightshift */
  1006. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1007. 6, /* bitsize */
  1008. FALSE, /* pc_relative */
  1009. 6, /* bitpos */
  1010. complain_overflow_bitfield, /* complain_on_overflow */
  1011. mips_elf_shift6_reloc, /* special_function */
  1012. "R_MIPS_SHIFT6", /* name */
  1013. FALSE, /* partial_inplace */
  1014. 0, /* src_mask */
  1015. 0x000007c4, /* dst_mask */
  1016. FALSE), /* pcrel_offset */
  1017. /* 64 bit relocation. */
  1018. HOWTO (R_MIPS_64, /* type */
  1019. 0, /* rightshift */
  1020. 4, /* size (0 = byte, 1 = short, 2 = long) */
  1021. 64, /* bitsize */
  1022. FALSE, /* pc_relative */
  1023. 0, /* bitpos */
  1024. complain_overflow_dont, /* complain_on_overflow */
  1025. _bfd_mips_elf_generic_reloc, /* special_function */
  1026. "R_MIPS_64", /* name */
  1027. FALSE, /* partial_inplace */
  1028. 0, /* src_mask */
  1029. MINUS_ONE, /* dst_mask */
  1030. FALSE), /* pcrel_offset */
  1031. /* Displacement in the global offset table. */
  1032. HOWTO (R_MIPS_GOT_DISP, /* type */
  1033. 0, /* rightshift */
  1034. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1035. 16, /* bitsize */
  1036. FALSE, /* pc_relative */
  1037. 0, /* bitpos */
  1038. complain_overflow_signed, /* complain_on_overflow */
  1039. _bfd_mips_elf_generic_reloc, /* special_function */
  1040. "R_MIPS_GOT_DISP", /* name */
  1041. FALSE, /* partial_inplace */
  1042. 0, /* src_mask */
  1043. 0x0000ffff, /* dst_mask */
  1044. FALSE), /* pcrel_offset */
  1045. /* Displacement to page pointer in the global offset table. */
  1046. HOWTO (R_MIPS_GOT_PAGE, /* type */
  1047. 0, /* rightshift */
  1048. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1049. 16, /* bitsize */
  1050. FALSE, /* pc_relative */
  1051. 0, /* bitpos */
  1052. complain_overflow_signed, /* complain_on_overflow */
  1053. _bfd_mips_elf_generic_reloc, /* special_function */
  1054. "R_MIPS_GOT_PAGE", /* name */
  1055. FALSE, /* partial_inplace */
  1056. 0, /* src_mask */
  1057. 0x0000ffff, /* dst_mask */
  1058. FALSE), /* pcrel_offset */
  1059. /* Offset from page pointer in the global offset table. */
  1060. HOWTO (R_MIPS_GOT_OFST, /* type */
  1061. 0, /* rightshift */
  1062. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1063. 16, /* bitsize */
  1064. FALSE, /* pc_relative */
  1065. 0, /* bitpos */
  1066. complain_overflow_signed, /* complain_on_overflow */
  1067. _bfd_mips_elf_generic_reloc, /* special_function */
  1068. "R_MIPS_GOT_OFST", /* name */
  1069. FALSE, /* partial_inplace */
  1070. 0, /* src_mask */
  1071. 0x0000ffff, /* dst_mask */
  1072. FALSE), /* pcrel_offset */
  1073. /* High 16 bits of displacement in global offset table. */
  1074. HOWTO (R_MIPS_GOT_HI16, /* type */
  1075. 0, /* rightshift */
  1076. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1077. 16, /* bitsize */
  1078. FALSE, /* pc_relative */
  1079. 0, /* bitpos */
  1080. complain_overflow_dont, /* complain_on_overflow */
  1081. _bfd_mips_elf_generic_reloc, /* special_function */
  1082. "R_MIPS_GOT_HI16", /* name */
  1083. FALSE, /* partial_inplace */
  1084. 0, /* src_mask */
  1085. 0x0000ffff, /* dst_mask */
  1086. FALSE), /* pcrel_offset */
  1087. /* Low 16 bits of displacement in global offset table. */
  1088. HOWTO (R_MIPS_GOT_LO16, /* type */
  1089. 0, /* rightshift */
  1090. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1091. 16, /* bitsize */
  1092. FALSE, /* pc_relative */
  1093. 0, /* bitpos */
  1094. complain_overflow_dont, /* complain_on_overflow */
  1095. _bfd_mips_elf_generic_reloc, /* special_function */
  1096. "R_MIPS_GOT_LO16", /* name */
  1097. FALSE, /* partial_inplace */
  1098. 0, /* src_mask */
  1099. 0x0000ffff, /* dst_mask */
  1100. FALSE), /* pcrel_offset */
  1101. /* 64 bit subtraction. */
  1102. HOWTO (R_MIPS_SUB, /* type */
  1103. 0, /* rightshift */
  1104. 4, /* size (0 = byte, 1 = short, 2 = long) */
  1105. 64, /* bitsize */
  1106. FALSE, /* pc_relative */
  1107. 0, /* bitpos */
  1108. complain_overflow_dont, /* complain_on_overflow */
  1109. _bfd_mips_elf_generic_reloc, /* special_function */
  1110. "R_MIPS_SUB", /* name */
  1111. FALSE, /* partial_inplace */
  1112. 0, /* src_mask */
  1113. MINUS_ONE, /* dst_mask */
  1114. FALSE), /* pcrel_offset */
  1115. /* Insert the addend as an instruction. */
  1116. /* FIXME: Not handled correctly. */
  1117. HOWTO (R_MIPS_INSERT_A, /* type */
  1118. 0, /* rightshift */
  1119. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1120. 32, /* bitsize */
  1121. FALSE, /* pc_relative */
  1122. 0, /* bitpos */
  1123. complain_overflow_dont, /* complain_on_overflow */
  1124. _bfd_mips_elf_generic_reloc, /* special_function */
  1125. "R_MIPS_INSERT_A", /* name */
  1126. FALSE, /* partial_inplace */
  1127. 0, /* src_mask */
  1128. 0xffffffff, /* dst_mask */
  1129. FALSE), /* pcrel_offset */
  1130. /* Insert the addend as an instruction, and change all relocations
  1131. to refer to the old instruction at the address. */
  1132. /* FIXME: Not handled correctly. */
  1133. HOWTO (R_MIPS_INSERT_B, /* type */
  1134. 0, /* rightshift */
  1135. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1136. 32, /* bitsize */
  1137. FALSE, /* pc_relative */
  1138. 0, /* bitpos */
  1139. complain_overflow_dont, /* complain_on_overflow */
  1140. _bfd_mips_elf_generic_reloc, /* special_function */
  1141. "R_MIPS_INSERT_B", /* name */
  1142. FALSE, /* partial_inplace */
  1143. 0, /* src_mask */
  1144. 0xffffffff, /* dst_mask */
  1145. FALSE), /* pcrel_offset */
  1146. /* Delete a 32 bit instruction. */
  1147. /* FIXME: Not handled correctly. */
  1148. HOWTO (R_MIPS_DELETE, /* type */
  1149. 0, /* rightshift */
  1150. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1151. 32, /* bitsize */
  1152. FALSE, /* pc_relative */
  1153. 0, /* bitpos */
  1154. complain_overflow_dont, /* complain_on_overflow */
  1155. _bfd_mips_elf_generic_reloc, /* special_function */
  1156. "R_MIPS_DELETE", /* name */
  1157. FALSE, /* partial_inplace */
  1158. 0, /* src_mask */
  1159. 0xffffffff, /* dst_mask */
  1160. FALSE), /* pcrel_offset */
  1161. /* Get the higher value of a 64 bit addend. */
  1162. HOWTO (R_MIPS_HIGHER, /* type */
  1163. 0, /* rightshift */
  1164. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1165. 16, /* bitsize */
  1166. FALSE, /* pc_relative */
  1167. 0, /* bitpos */
  1168. complain_overflow_dont, /* complain_on_overflow */
  1169. _bfd_mips_elf_generic_reloc, /* special_function */
  1170. "R_MIPS_HIGHER", /* name */
  1171. FALSE, /* partial_inplace */
  1172. 0, /* src_mask */
  1173. 0x0000ffff, /* dst_mask */
  1174. FALSE), /* pcrel_offset */
  1175. /* Get the highest value of a 64 bit addend. */
  1176. HOWTO (R_MIPS_HIGHEST, /* type */
  1177. 0, /* rightshift */
  1178. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1179. 16, /* bitsize */
  1180. FALSE, /* pc_relative */
  1181. 0, /* bitpos */
  1182. complain_overflow_dont, /* complain_on_overflow */
  1183. _bfd_mips_elf_generic_reloc, /* special_function */
  1184. "R_MIPS_HIGHEST", /* name */
  1185. FALSE, /* partial_inplace */
  1186. 0, /* src_mask */
  1187. 0x0000ffff, /* dst_mask */
  1188. FALSE), /* pcrel_offset */
  1189. /* High 16 bits of displacement in global offset table. */
  1190. HOWTO (R_MIPS_CALL_HI16, /* type */
  1191. 0, /* rightshift */
  1192. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1193. 16, /* bitsize */
  1194. FALSE, /* pc_relative */
  1195. 0, /* bitpos */
  1196. complain_overflow_dont, /* complain_on_overflow */
  1197. _bfd_mips_elf_generic_reloc, /* special_function */
  1198. "R_MIPS_CALL_HI16", /* name */
  1199. FALSE, /* partial_inplace */
  1200. 0, /* src_mask */
  1201. 0x0000ffff, /* dst_mask */
  1202. FALSE), /* pcrel_offset */
  1203. /* Low 16 bits of displacement in global offset table. */
  1204. HOWTO (R_MIPS_CALL_LO16, /* type */
  1205. 0, /* rightshift */
  1206. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1207. 16, /* bitsize */
  1208. FALSE, /* pc_relative */
  1209. 0, /* bitpos */
  1210. complain_overflow_dont, /* complain_on_overflow */
  1211. _bfd_mips_elf_generic_reloc, /* special_function */
  1212. "R_MIPS_CALL_LO16", /* name */
  1213. FALSE, /* partial_inplace */
  1214. 0, /* src_mask */
  1215. 0x0000ffff, /* dst_mask */
  1216. FALSE), /* pcrel_offset */
  1217. /* Section displacement, used by an associated event location section. */
  1218. HOWTO (R_MIPS_SCN_DISP, /* type */
  1219. 0, /* rightshift */
  1220. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1221. 32, /* bitsize */
  1222. FALSE, /* pc_relative */
  1223. 0, /* bitpos */
  1224. complain_overflow_dont, /* complain_on_overflow */
  1225. _bfd_mips_elf_generic_reloc, /* special_function */
  1226. "R_MIPS_SCN_DISP", /* name */
  1227. FALSE, /* partial_inplace */
  1228. 0, /* src_mask */
  1229. 0xffffffff, /* dst_mask */
  1230. FALSE), /* pcrel_offset */
  1231. /* 16 bit relocation. */
  1232. HOWTO (R_MIPS_REL16, /* type */
  1233. 0, /* rightshift */
  1234. 1, /* size (0 = byte, 1 = short, 2 = long) */
  1235. 16, /* bitsize */
  1236. FALSE, /* pc_relative */
  1237. 0, /* bitpos */
  1238. complain_overflow_signed, /* complain_on_overflow */
  1239. _bfd_mips_elf_generic_reloc, /* special_function */
  1240. "R_MIPS_REL16", /* name */
  1241. FALSE, /* partial_inplace */
  1242. 0, /* src_mask */
  1243. 0xffff, /* dst_mask */
  1244. FALSE), /* pcrel_offset */
  1245. /* These two are obsolete. */
  1246. EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
  1247. EMPTY_HOWTO (R_MIPS_PJUMP),
  1248. /* Similiar to R_MIPS_REL32, but used for relocations in a GOT section.
  1249. It must be used for multigot GOT's (and only there). */
  1250. HOWTO (R_MIPS_RELGOT, /* type */
  1251. 0, /* rightshift */
  1252. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1253. 32, /* bitsize */
  1254. FALSE, /* pc_relative */
  1255. 0, /* bitpos */
  1256. complain_overflow_dont, /* complain_on_overflow */
  1257. _bfd_mips_elf_generic_reloc, /* special_function */
  1258. "R_MIPS_RELGOT", /* name */
  1259. FALSE, /* partial_inplace */
  1260. 0, /* src_mask */
  1261. 0xffffffff, /* dst_mask */
  1262. FALSE), /* pcrel_offset */
  1263. /* Protected jump conversion. This is an optimization hint. No
  1264. relocation is required for correctness. */
  1265. HOWTO (R_MIPS_JALR, /* type */
  1266. 0, /* rightshift */
  1267. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1268. 32, /* bitsize */
  1269. FALSE, /* pc_relative */
  1270. 0, /* bitpos */
  1271. complain_overflow_dont, /* complain_on_overflow */
  1272. _bfd_mips_elf_generic_reloc, /* special_function */
  1273. "R_MIPS_JALR", /* name */
  1274. FALSE, /* partial_inplace */
  1275. 0, /* src_mask */
  1276. 0, /* dst_mask */
  1277. FALSE), /* pcrel_offset */
  1278. /* TLS GD/LD dynamic relocations. */
  1279. HOWTO (R_MIPS_TLS_DTPMOD32, /* type */
  1280. 0, /* rightshift */
  1281. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1282. 32, /* bitsize */
  1283. FALSE, /* pc_relative */
  1284. 0, /* bitpos */
  1285. complain_overflow_dont, /* complain_on_overflow */
  1286. _bfd_mips_elf_generic_reloc, /* special_function */
  1287. "R_MIPS_TLS_DTPMOD32", /* name */
  1288. FALSE, /* partial_inplace */
  1289. 0, /* src_mask */
  1290. 0xffffffff, /* dst_mask */
  1291. FALSE), /* pcrel_offset */
  1292. HOWTO (R_MIPS_TLS_DTPREL32, /* type */
  1293. 0, /* rightshift */
  1294. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1295. 32, /* bitsize */
  1296. FALSE, /* pc_relative */
  1297. 0, /* bitpos */
  1298. complain_overflow_dont, /* complain_on_overflow */
  1299. _bfd_mips_elf_generic_reloc, /* special_function */
  1300. "R_MIPS_TLS_DTPREL32", /* name */
  1301. FALSE, /* partial_inplace */
  1302. 0, /* src_mask */
  1303. 0xffffffff, /* dst_mask */
  1304. FALSE), /* pcrel_offset */
  1305. EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
  1306. EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
  1307. /* TLS general dynamic variable reference. */
  1308. HOWTO (R_MIPS_TLS_GD, /* type */
  1309. 0, /* rightshift */
  1310. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1311. 16, /* bitsize */
  1312. FALSE, /* pc_relative */
  1313. 0, /* bitpos */
  1314. complain_overflow_signed, /* complain_on_overflow */
  1315. _bfd_mips_elf_generic_reloc, /* special_function */
  1316. "R_MIPS_TLS_GD", /* name */
  1317. FALSE, /* partial_inplace */
  1318. 0, /* src_mask */
  1319. 0x0000ffff, /* dst_mask */
  1320. FALSE), /* pcrel_offset */
  1321. /* TLS local dynamic variable reference. */
  1322. HOWTO (R_MIPS_TLS_LDM, /* type */
  1323. 0, /* rightshift */
  1324. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1325. 16, /* bitsize */
  1326. FALSE, /* pc_relative */
  1327. 0, /* bitpos */
  1328. complain_overflow_signed, /* complain_on_overflow */
  1329. _bfd_mips_elf_generic_reloc, /* special_function */
  1330. "R_MIPS_TLS_LDM", /* name */
  1331. FALSE, /* partial_inplace */
  1332. 0, /* src_mask */
  1333. 0x0000ffff, /* dst_mask */
  1334. FALSE), /* pcrel_offset */
  1335. /* TLS local dynamic offset. */
  1336. HOWTO (R_MIPS_TLS_DTPREL_HI16, /* type */
  1337. 0, /* rightshift */
  1338. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1339. 16, /* bitsize */
  1340. FALSE, /* pc_relative */
  1341. 0, /* bitpos */
  1342. complain_overflow_signed, /* complain_on_overflow */
  1343. _bfd_mips_elf_generic_reloc, /* special_function */
  1344. "R_MIPS_TLS_DTPREL_HI16", /* name */
  1345. FALSE, /* partial_inplace */
  1346. 0, /* src_mask */
  1347. 0x0000ffff, /* dst_mask */
  1348. FALSE), /* pcrel_offset */
  1349. /* TLS local dynamic offset. */
  1350. HOWTO (R_MIPS_TLS_DTPREL_LO16, /* type */
  1351. 0, /* rightshift */
  1352. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1353. 16, /* bitsize */
  1354. FALSE, /* pc_relative */
  1355. 0, /* bitpos */
  1356. complain_overflow_signed, /* complain_on_overflow */
  1357. _bfd_mips_elf_generic_reloc, /* special_function */
  1358. "R_MIPS_TLS_DTPREL_LO16", /* name */
  1359. FALSE, /* partial_inplace */
  1360. 0, /* src_mask */
  1361. 0x0000ffff, /* dst_mask */
  1362. FALSE), /* pcrel_offset */
  1363. /* TLS thread pointer offset. */
  1364. HOWTO (R_MIPS_TLS_GOTTPREL, /* type */
  1365. 0, /* rightshift */
  1366. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1367. 16, /* bitsize */
  1368. FALSE, /* pc_relative */
  1369. 0, /* bitpos */
  1370. complain_overflow_signed, /* complain_on_overflow */
  1371. _bfd_mips_elf_generic_reloc, /* special_function */
  1372. "R_MIPS_TLS_GOTTPREL", /* name */
  1373. FALSE, /* partial_inplace */
  1374. 0, /* src_mask */
  1375. 0x0000ffff, /* dst_mask */
  1376. FALSE), /* pcrel_offset */
  1377. /* TLS IE dynamic relocations. */
  1378. HOWTO (R_MIPS_TLS_TPREL32, /* type */
  1379. 0, /* rightshift */
  1380. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1381. 32, /* bitsize */
  1382. FALSE, /* pc_relative */
  1383. 0, /* bitpos */
  1384. complain_overflow_dont, /* complain_on_overflow */
  1385. _bfd_mips_elf_generic_reloc, /* special_function */
  1386. "R_MIPS_TLS_TPREL32", /* name */
  1387. FALSE, /* partial_inplace */
  1388. 0, /* src_mask */
  1389. 0xffffffff, /* dst_mask */
  1390. FALSE), /* pcrel_offset */
  1391. EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
  1392. /* TLS thread pointer offset. */
  1393. HOWTO (R_MIPS_TLS_TPREL_HI16, /* type */
  1394. 0, /* rightshift */
  1395. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1396. 16, /* bitsize */
  1397. FALSE, /* pc_relative */
  1398. 0, /* bitpos */
  1399. complain_overflow_signed, /* complain_on_overflow */
  1400. _bfd_mips_elf_generic_reloc, /* special_function */
  1401. "R_MIPS_TLS_TPREL_HI16", /* name */
  1402. FALSE, /* partial_inplace */
  1403. 0, /* src_mask */
  1404. 0x0000ffff, /* dst_mask */
  1405. FALSE), /* pcrel_offset */
  1406. /* TLS thread pointer offset. */
  1407. HOWTO (R_MIPS_TLS_TPREL_LO16, /* type */
  1408. 0, /* rightshift */
  1409. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1410. 16, /* bitsize */
  1411. FALSE, /* pc_relative */
  1412. 0, /* bitpos */
  1413. complain_overflow_signed, /* complain_on_overflow */
  1414. _bfd_mips_elf_generic_reloc, /* special_function */
  1415. "R_MIPS_TLS_TPREL_LO16", /* name */
  1416. FALSE, /* partial_inplace */
  1417. 0, /* src_mask */
  1418. 0x0000ffff, /* dst_mask */
  1419. FALSE), /* pcrel_offset */
  1420. /* 32 bit relocation with no addend. */
  1421. HOWTO (R_MIPS_GLOB_DAT, /* type */
  1422. 0, /* rightshift */
  1423. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1424. 32, /* bitsize */
  1425. FALSE, /* pc_relative */
  1426. 0, /* bitpos */
  1427. complain_overflow_dont, /* complain_on_overflow */
  1428. _bfd_mips_elf_generic_reloc, /* special_function */
  1429. "R_MIPS_GLOB_DAT", /* name */
  1430. FALSE, /* partial_inplace */
  1431. 0x0, /* src_mask */
  1432. 0xffffffff, /* dst_mask */
  1433. FALSE), /* pcrel_offset */
  1434. EMPTY_HOWTO (52),
  1435. EMPTY_HOWTO (53),
  1436. EMPTY_HOWTO (54),
  1437. EMPTY_HOWTO (55),
  1438. EMPTY_HOWTO (56),
  1439. EMPTY_HOWTO (57),
  1440. EMPTY_HOWTO (58),
  1441. EMPTY_HOWTO (59),
  1442. HOWTO (R_MIPS_PC21_S2, /* type */
  1443. 2, /* rightshift */
  1444. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1445. 21, /* bitsize */
  1446. TRUE, /* pc_relative */
  1447. 0, /* bitpos */
  1448. complain_overflow_signed, /* complain_on_overflow */
  1449. _bfd_mips_elf_generic_reloc, /* special_function */
  1450. "R_MIPS_PC21_S2", /* name */
  1451. FALSE, /* partial_inplace */
  1452. 0, /* src_mask */
  1453. 0x001fffff, /* dst_mask */
  1454. TRUE), /* pcrel_offset */
  1455. HOWTO (R_MIPS_PC26_S2, /* type */
  1456. 2, /* rightshift */
  1457. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1458. 26, /* bitsize */
  1459. TRUE, /* pc_relative */
  1460. 0, /* bitpos */
  1461. complain_overflow_signed, /* complain_on_overflow */
  1462. _bfd_mips_elf_generic_reloc, /* special_function */
  1463. "R_MIPS_PC26_S2", /* name */
  1464. FALSE, /* partial_inplace */
  1465. 0, /* src_mask */
  1466. 0x03ffffff, /* dst_mask */
  1467. TRUE), /* pcrel_offset */
  1468. HOWTO (R_MIPS_PC18_S3, /* type */
  1469. 3, /* rightshift */
  1470. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1471. 18, /* bitsize */
  1472. TRUE, /* pc_relative */
  1473. 0, /* bitpos */
  1474. complain_overflow_signed, /* complain_on_overflow */
  1475. _bfd_mips_elf_generic_reloc, /* special_function */
  1476. "R_MIPS_PC18_S3", /* name */
  1477. FALSE, /* partial_inplace */
  1478. 0, /* src_mask */
  1479. 0x0003ffff, /* dst_mask */
  1480. TRUE), /* pcrel_offset */
  1481. HOWTO (R_MIPS_PC19_S2, /* type */
  1482. 2, /* rightshift */
  1483. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1484. 19, /* bitsize */
  1485. TRUE, /* pc_relative */
  1486. 0, /* bitpos */
  1487. complain_overflow_signed, /* complain_on_overflow */
  1488. _bfd_mips_elf_generic_reloc, /* special_function */
  1489. "R_MIPS_PC19_S2", /* name */
  1490. FALSE, /* partial_inplace */
  1491. 0, /* src_mask */
  1492. 0x0007ffff, /* dst_mask */
  1493. TRUE), /* pcrel_offset */
  1494. HOWTO (R_MIPS_PCHI16, /* type */
  1495. 16, /* rightshift */
  1496. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1497. 16, /* bitsize */
  1498. TRUE, /* pc_relative */
  1499. 0, /* bitpos */
  1500. complain_overflow_signed, /* complain_on_overflow */
  1501. _bfd_mips_elf_generic_reloc, /* special_function */
  1502. "R_MIPS_PCHI16", /* name */
  1503. FALSE, /* partial_inplace */
  1504. 0, /* src_mask */
  1505. 0x0000ffff, /* dst_mask */
  1506. TRUE), /* pcrel_offset */
  1507. HOWTO (R_MIPS_PCLO16, /* type */
  1508. 0, /* rightshift */
  1509. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1510. 16, /* bitsize */
  1511. TRUE, /* pc_relative */
  1512. 0, /* bitpos */
  1513. complain_overflow_dont, /* complain_on_overflow */
  1514. _bfd_mips_elf_generic_reloc, /* special_function */
  1515. "R_MIPS_PCLO16", /* name */
  1516. FALSE, /* partial_inplace */
  1517. 0, /* src_mask */
  1518. 0x0000ffff, /* dst_mask */
  1519. TRUE), /* pcrel_offset */
  1520. };
  1521. static reloc_howto_type elf_mips16_howto_table_rel[] =
  1522. {
  1523. /* The reloc used for the mips16 jump instruction. */
  1524. HOWTO (R_MIPS16_26, /* type */
  1525. 2, /* rightshift */
  1526. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1527. 26, /* bitsize */
  1528. FALSE, /* pc_relative */
  1529. 0, /* bitpos */
  1530. complain_overflow_dont, /* complain_on_overflow */
  1531. /* This needs complex overflow
  1532. detection, because the upper four
  1533. bits must match the PC. */
  1534. _bfd_mips_elf_generic_reloc, /* special_function */
  1535. "R_MIPS16_26", /* name */
  1536. TRUE, /* partial_inplace */
  1537. 0x3ffffff, /* src_mask */
  1538. 0x3ffffff, /* dst_mask */
  1539. FALSE), /* pcrel_offset */
  1540. /* The reloc used for the mips16 gprel instruction. */
  1541. HOWTO (R_MIPS16_GPREL, /* type */
  1542. 0, /* rightshift */
  1543. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1544. 16, /* bitsize */
  1545. FALSE, /* pc_relative */
  1546. 0, /* bitpos */
  1547. complain_overflow_signed, /* complain_on_overflow */
  1548. mips16_gprel_reloc, /* special_function */
  1549. "R_MIPS16_GPREL", /* name */
  1550. TRUE, /* partial_inplace */
  1551. 0x0000ffff, /* src_mask */
  1552. 0x0000ffff, /* dst_mask */
  1553. FALSE), /* pcrel_offset */
  1554. /* A MIPS16 reference to the global offset table. */
  1555. HOWTO (R_MIPS16_GOT16, /* type */
  1556. 0, /* rightshift */
  1557. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1558. 16, /* bitsize */
  1559. FALSE, /* pc_relative */
  1560. 0, /* bitpos */
  1561. complain_overflow_dont, /* complain_on_overflow */
  1562. _bfd_mips_elf_got16_reloc, /* special_function */
  1563. "R_MIPS16_GOT16", /* name */
  1564. TRUE, /* partial_inplace */
  1565. 0x0000ffff, /* src_mask */
  1566. 0x0000ffff, /* dst_mask */
  1567. FALSE), /* pcrel_offset */
  1568. /* A MIPS16 call through the global offset table. */
  1569. HOWTO (R_MIPS16_CALL16, /* type */
  1570. 0, /* rightshift */
  1571. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1572. 16, /* bitsize */
  1573. FALSE, /* pc_relative */
  1574. 0, /* bitpos */
  1575. complain_overflow_dont, /* complain_on_overflow */
  1576. _bfd_mips_elf_generic_reloc, /* special_function */
  1577. "R_MIPS16_CALL16", /* name */
  1578. TRUE, /* partial_inplace */
  1579. 0x0000ffff, /* src_mask */
  1580. 0x0000ffff, /* dst_mask */
  1581. FALSE), /* pcrel_offset */
  1582. /* MIPS16 high 16 bits of symbol value. */
  1583. HOWTO (R_MIPS16_HI16, /* type */
  1584. 16, /* rightshift */
  1585. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1586. 16, /* bitsize */
  1587. FALSE, /* pc_relative */
  1588. 0, /* bitpos */
  1589. complain_overflow_dont, /* complain_on_overflow */
  1590. _bfd_mips_elf_hi16_reloc, /* special_function */
  1591. "R_MIPS16_HI16", /* name */
  1592. TRUE, /* partial_inplace */
  1593. 0x0000ffff, /* src_mask */
  1594. 0x0000ffff, /* dst_mask */
  1595. FALSE), /* pcrel_offset */
  1596. /* MIPS16 low 16 bits of symbol value. */
  1597. HOWTO (R_MIPS16_LO16, /* type */
  1598. 0, /* rightshift */
  1599. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1600. 16, /* bitsize */
  1601. FALSE, /* pc_relative */
  1602. 0, /* bitpos */
  1603. complain_overflow_dont, /* complain_on_overflow */
  1604. _bfd_mips_elf_lo16_reloc, /* special_function */
  1605. "R_MIPS16_LO16", /* name */
  1606. TRUE, /* partial_inplace */
  1607. 0x0000ffff, /* src_mask */
  1608. 0x0000ffff, /* dst_mask */
  1609. FALSE), /* pcrel_offset */
  1610. /* MIPS16 TLS general dynamic variable reference. */
  1611. HOWTO (R_MIPS16_TLS_GD, /* type */
  1612. 0, /* rightshift */
  1613. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1614. 16, /* bitsize */
  1615. FALSE, /* pc_relative */
  1616. 0, /* bitpos */
  1617. complain_overflow_signed, /* complain_on_overflow */
  1618. _bfd_mips_elf_generic_reloc, /* special_function */
  1619. "R_MIPS16_TLS_GD", /* name */
  1620. TRUE, /* partial_inplace */
  1621. 0x0000ffff, /* src_mask */
  1622. 0x0000ffff, /* dst_mask */
  1623. FALSE), /* pcrel_offset */
  1624. /* MIPS16 TLS local dynamic variable reference. */
  1625. HOWTO (R_MIPS16_TLS_LDM, /* type */
  1626. 0, /* rightshift */
  1627. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1628. 16, /* bitsize */
  1629. FALSE, /* pc_relative */
  1630. 0, /* bitpos */
  1631. complain_overflow_signed, /* complain_on_overflow */
  1632. _bfd_mips_elf_generic_reloc, /* special_function */
  1633. "R_MIPS16_TLS_LDM", /* name */
  1634. TRUE, /* partial_inplace */
  1635. 0x0000ffff, /* src_mask */
  1636. 0x0000ffff, /* dst_mask */
  1637. FALSE), /* pcrel_offset */
  1638. /* MIPS16 TLS local dynamic offset. */
  1639. HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */
  1640. 0, /* rightshift */
  1641. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1642. 16, /* bitsize */
  1643. FALSE, /* pc_relative */
  1644. 0, /* bitpos */
  1645. complain_overflow_signed, /* complain_on_overflow */
  1646. _bfd_mips_elf_generic_reloc, /* special_function */
  1647. "R_MIPS16_TLS_DTPREL_HI16", /* name */
  1648. TRUE, /* partial_inplace */
  1649. 0x0000ffff, /* src_mask */
  1650. 0x0000ffff, /* dst_mask */
  1651. FALSE), /* pcrel_offset */
  1652. /* MIPS16 TLS local dynamic offset. */
  1653. HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */
  1654. 0, /* rightshift */
  1655. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1656. 16, /* bitsize */
  1657. FALSE, /* pc_relative */
  1658. 0, /* bitpos */
  1659. complain_overflow_signed, /* complain_on_overflow */
  1660. _bfd_mips_elf_generic_reloc, /* special_function */
  1661. "R_MIPS16_TLS_DTPREL_LO16", /* name */
  1662. TRUE, /* partial_inplace */
  1663. 0x0000ffff, /* src_mask */
  1664. 0x0000ffff, /* dst_mask */
  1665. FALSE), /* pcrel_offset */
  1666. /* MIPS16 TLS thread pointer offset. */
  1667. HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */
  1668. 0, /* rightshift */
  1669. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1670. 16, /* bitsize */
  1671. FALSE, /* pc_relative */
  1672. 0, /* bitpos */
  1673. complain_overflow_signed, /* complain_on_overflow */
  1674. _bfd_mips_elf_generic_reloc, /* special_function */
  1675. "R_MIPS16_TLS_GOTTPREL", /* name */
  1676. TRUE, /* partial_inplace */
  1677. 0x0000ffff, /* src_mask */
  1678. 0x0000ffff, /* dst_mask */
  1679. FALSE), /* pcrel_offset */
  1680. /* MIPS16 TLS thread pointer offset. */
  1681. HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */
  1682. 0, /* rightshift */
  1683. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1684. 16, /* bitsize */
  1685. FALSE, /* pc_relative */
  1686. 0, /* bitpos */
  1687. complain_overflow_signed, /* complain_on_overflow */
  1688. _bfd_mips_elf_generic_reloc, /* special_function */
  1689. "R_MIPS16_TLS_TPREL_HI16", /* name */
  1690. TRUE, /* partial_inplace */
  1691. 0x0000ffff, /* src_mask */
  1692. 0x0000ffff, /* dst_mask */
  1693. FALSE), /* pcrel_offset */
  1694. /* MIPS16 TLS thread pointer offset. */
  1695. HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */
  1696. 0, /* rightshift */
  1697. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1698. 16, /* bitsize */
  1699. FALSE, /* pc_relative */
  1700. 0, /* bitpos */
  1701. complain_overflow_signed, /* complain_on_overflow */
  1702. _bfd_mips_elf_generic_reloc, /* special_function */
  1703. "R_MIPS16_TLS_TPREL_LO16", /* name */
  1704. TRUE, /* partial_inplace */
  1705. 0x0000ffff, /* src_mask */
  1706. 0x0000ffff, /* dst_mask */
  1707. FALSE), /* pcrel_offset */
  1708. };
  1709. static reloc_howto_type elf_mips16_howto_table_rela[] =
  1710. {
  1711. /* The reloc used for the mips16 jump instruction. */
  1712. HOWTO (R_MIPS16_26, /* type */
  1713. 2, /* rightshift */
  1714. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1715. 26, /* bitsize */
  1716. FALSE, /* pc_relative */
  1717. 0, /* bitpos */
  1718. complain_overflow_dont, /* complain_on_overflow */
  1719. /* This needs complex overflow
  1720. detection, because the upper four
  1721. bits must match the PC. */
  1722. _bfd_mips_elf_generic_reloc, /* special_function */
  1723. "R_MIPS16_26", /* name */
  1724. FALSE, /* partial_inplace */
  1725. 0, /* src_mask */
  1726. 0x3ffffff, /* dst_mask */
  1727. FALSE), /* pcrel_offset */
  1728. /* The reloc used for the mips16 gprel instruction. */
  1729. HOWTO (R_MIPS16_GPREL, /* type */
  1730. 0, /* rightshift */
  1731. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1732. 16, /* bitsize */
  1733. FALSE, /* pc_relative */
  1734. 0, /* bitpos */
  1735. complain_overflow_signed, /* complain_on_overflow */
  1736. mips16_gprel_reloc, /* special_function */
  1737. "R_MIPS16_GPREL", /* name */
  1738. FALSE, /* partial_inplace */
  1739. 0, /* src_mask */
  1740. 0x0000ffff, /* dst_mask */
  1741. FALSE), /* pcrel_offset */
  1742. /* A MIPS16 reference to the global offset table. */
  1743. HOWTO (R_MIPS16_GOT16, /* type */
  1744. 0, /* rightshift */
  1745. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1746. 16, /* bitsize */
  1747. FALSE, /* pc_relative */
  1748. 0, /* bitpos */
  1749. complain_overflow_dont, /* complain_on_overflow */
  1750. _bfd_mips_elf_got16_reloc, /* special_function */
  1751. "R_MIPS16_GOT16", /* name */
  1752. FALSE, /* partial_inplace */
  1753. 0, /* src_mask */
  1754. 0x0000ffff, /* dst_mask */
  1755. FALSE), /* pcrel_offset */
  1756. /* A MIPS16 call through the global offset table. */
  1757. HOWTO (R_MIPS16_CALL16, /* type */
  1758. 0, /* rightshift */
  1759. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1760. 16, /* bitsize */
  1761. FALSE, /* pc_relative */
  1762. 0, /* bitpos */
  1763. complain_overflow_dont, /* complain_on_overflow */
  1764. _bfd_mips_elf_generic_reloc, /* special_function */
  1765. "R_MIPS16_CALL16", /* name */
  1766. FALSE, /* partial_inplace */
  1767. 0, /* src_mask */
  1768. 0x0000ffff, /* dst_mask */
  1769. FALSE), /* pcrel_offset */
  1770. /* MIPS16 high 16 bits of symbol value. */
  1771. HOWTO (R_MIPS16_HI16, /* type */
  1772. 16, /* rightshift */
  1773. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1774. 16, /* bitsize */
  1775. FALSE, /* pc_relative */
  1776. 0, /* bitpos */
  1777. complain_overflow_dont, /* complain_on_overflow */
  1778. _bfd_mips_elf_hi16_reloc, /* special_function */
  1779. "R_MIPS16_HI16", /* name */
  1780. FALSE, /* partial_inplace */
  1781. 0, /* src_mask */
  1782. 0x0000ffff, /* dst_mask */
  1783. FALSE), /* pcrel_offset */
  1784. /* MIPS16 low 16 bits of symbol value. */
  1785. HOWTO (R_MIPS16_LO16, /* type */
  1786. 0, /* rightshift */
  1787. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1788. 16, /* bitsize */
  1789. FALSE, /* pc_relative */
  1790. 0, /* bitpos */
  1791. complain_overflow_dont, /* complain_on_overflow */
  1792. _bfd_mips_elf_lo16_reloc, /* special_function */
  1793. "R_MIPS16_LO16", /* name */
  1794. FALSE, /* partial_inplace */
  1795. 0, /* src_mask */
  1796. 0x0000ffff, /* dst_mask */
  1797. FALSE), /* pcrel_offset */
  1798. /* MIPS16 TLS general dynamic variable reference. */
  1799. HOWTO (R_MIPS16_TLS_GD, /* type */
  1800. 0, /* rightshift */
  1801. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1802. 16, /* bitsize */
  1803. FALSE, /* pc_relative */
  1804. 0, /* bitpos */
  1805. complain_overflow_signed, /* complain_on_overflow */
  1806. _bfd_mips_elf_generic_reloc, /* special_function */
  1807. "R_MIPS16_TLS_GD", /* name */
  1808. FALSE, /* partial_inplace */
  1809. 0, /* src_mask */
  1810. 0x0000ffff, /* dst_mask */
  1811. FALSE), /* pcrel_offset */
  1812. /* MIPS16 TLS local dynamic variable reference. */
  1813. HOWTO (R_MIPS16_TLS_LDM, /* type */
  1814. 0, /* rightshift */
  1815. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1816. 16, /* bitsize */
  1817. FALSE, /* pc_relative */
  1818. 0, /* bitpos */
  1819. complain_overflow_signed, /* complain_on_overflow */
  1820. _bfd_mips_elf_generic_reloc, /* special_function */
  1821. "R_MIPS16_TLS_LDM", /* name */
  1822. FALSE, /* partial_inplace */
  1823. 0, /* src_mask */
  1824. 0x0000ffff, /* dst_mask */
  1825. FALSE), /* pcrel_offset */
  1826. /* MIPS16 TLS local dynamic offset. */
  1827. HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */
  1828. 0, /* rightshift */
  1829. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1830. 16, /* bitsize */
  1831. FALSE, /* pc_relative */
  1832. 0, /* bitpos */
  1833. complain_overflow_signed, /* complain_on_overflow */
  1834. _bfd_mips_elf_generic_reloc, /* special_function */
  1835. "R_MIPS16_TLS_DTPREL_HI16", /* name */
  1836. FALSE, /* partial_inplace */
  1837. 0, /* src_mask */
  1838. 0x0000ffff, /* dst_mask */
  1839. FALSE), /* pcrel_offset */
  1840. /* MIPS16 TLS local dynamic offset. */
  1841. HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */
  1842. 0, /* rightshift */
  1843. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1844. 16, /* bitsize */
  1845. FALSE, /* pc_relative */
  1846. 0, /* bitpos */
  1847. complain_overflow_signed, /* complain_on_overflow */
  1848. _bfd_mips_elf_generic_reloc, /* special_function */
  1849. "R_MIPS16_TLS_DTPREL_LO16", /* name */
  1850. FALSE, /* partial_inplace */
  1851. 0, /* src_mask */
  1852. 0x0000ffff, /* dst_mask */
  1853. FALSE), /* pcrel_offset */
  1854. /* MIPS16 TLS thread pointer offset. */
  1855. HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */
  1856. 0, /* rightshift */
  1857. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1858. 16, /* bitsize */
  1859. FALSE, /* pc_relative */
  1860. 0, /* bitpos */
  1861. complain_overflow_signed, /* complain_on_overflow */
  1862. _bfd_mips_elf_generic_reloc, /* special_function */
  1863. "R_MIPS16_TLS_GOTTPREL", /* name */
  1864. FALSE, /* partial_inplace */
  1865. 0, /* src_mask */
  1866. 0x0000ffff, /* dst_mask */
  1867. FALSE), /* pcrel_offset */
  1868. /* MIPS16 TLS thread pointer offset. */
  1869. HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */
  1870. 0, /* rightshift */
  1871. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1872. 16, /* bitsize */
  1873. FALSE, /* pc_relative */
  1874. 0, /* bitpos */
  1875. complain_overflow_signed, /* complain_on_overflow */
  1876. _bfd_mips_elf_generic_reloc, /* special_function */
  1877. "R_MIPS16_TLS_TPREL_HI16", /* name */
  1878. FALSE, /* partial_inplace */
  1879. 0, /* src_mask */
  1880. 0x0000ffff, /* dst_mask */
  1881. FALSE), /* pcrel_offset */
  1882. /* MIPS16 TLS thread pointer offset. */
  1883. HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */
  1884. 0, /* rightshift */
  1885. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1886. 16, /* bitsize */
  1887. FALSE, /* pc_relative */
  1888. 0, /* bitpos */
  1889. complain_overflow_signed, /* complain_on_overflow */
  1890. _bfd_mips_elf_generic_reloc, /* special_function */
  1891. "R_MIPS16_TLS_TPREL_LO16", /* name */
  1892. FALSE, /* partial_inplace */
  1893. 0, /* src_mask */
  1894. 0x0000ffff, /* dst_mask */
  1895. FALSE), /* pcrel_offset */
  1896. };
  1897. static reloc_howto_type elf_micromips_howto_table_rel[] =
  1898. {
  1899. EMPTY_HOWTO (130),
  1900. EMPTY_HOWTO (131),
  1901. EMPTY_HOWTO (132),
  1902. /* 26 bit jump address. */
  1903. HOWTO (R_MICROMIPS_26_S1, /* type */
  1904. 1, /* rightshift */
  1905. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1906. 26, /* bitsize */
  1907. FALSE, /* pc_relative */
  1908. 0, /* bitpos */
  1909. complain_overflow_dont, /* complain_on_overflow */
  1910. /* This needs complex overflow
  1911. detection, because the upper four
  1912. bits must match the PC. */
  1913. _bfd_mips_elf_generic_reloc, /* special_function */
  1914. "R_MICROMIPS_26_S1", /* name */
  1915. TRUE, /* partial_inplace */
  1916. 0x3ffffff, /* src_mask */
  1917. 0x3ffffff, /* dst_mask */
  1918. FALSE), /* pcrel_offset */
  1919. /* High 16 bits of symbol value. */
  1920. HOWTO (R_MICROMIPS_HI16, /* type */
  1921. 16, /* rightshift */
  1922. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1923. 16, /* bitsize */
  1924. FALSE, /* pc_relative */
  1925. 0, /* bitpos */
  1926. complain_overflow_dont, /* complain_on_overflow */
  1927. _bfd_mips_elf_hi16_reloc, /* special_function */
  1928. "R_MICROMIPS_HI16", /* name */
  1929. TRUE, /* partial_inplace */
  1930. 0x0000ffff, /* src_mask */
  1931. 0x0000ffff, /* dst_mask */
  1932. FALSE), /* pcrel_offset */
  1933. /* Low 16 bits of symbol value. */
  1934. HOWTO (R_MICROMIPS_LO16, /* type */
  1935. 0, /* rightshift */
  1936. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1937. 16, /* bitsize */
  1938. FALSE, /* pc_relative */
  1939. 0, /* bitpos */
  1940. complain_overflow_dont, /* complain_on_overflow */
  1941. _bfd_mips_elf_lo16_reloc, /* special_function */
  1942. "R_MICROMIPS_LO16", /* name */
  1943. TRUE, /* partial_inplace */
  1944. 0x0000ffff, /* src_mask */
  1945. 0x0000ffff, /* dst_mask */
  1946. FALSE), /* pcrel_offset */
  1947. /* GP relative reference. */
  1948. HOWTO (R_MICROMIPS_GPREL16, /* type */
  1949. 0, /* rightshift */
  1950. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1951. 16, /* bitsize */
  1952. FALSE, /* pc_relative */
  1953. 0, /* bitpos */
  1954. complain_overflow_signed, /* complain_on_overflow */
  1955. _bfd_mips_elf32_gprel16_reloc, /* special_function */
  1956. "R_MICROMIPS_GPREL16", /* name */
  1957. TRUE, /* partial_inplace */
  1958. 0x0000ffff, /* src_mask */
  1959. 0x0000ffff, /* dst_mask */
  1960. FALSE), /* pcrel_offset */
  1961. /* Reference to literal section. */
  1962. HOWTO (R_MICROMIPS_LITERAL, /* type */
  1963. 0, /* rightshift */
  1964. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1965. 16, /* bitsize */
  1966. FALSE, /* pc_relative */
  1967. 0, /* bitpos */
  1968. complain_overflow_signed, /* complain_on_overflow */
  1969. _bfd_mips_elf32_gprel16_reloc, /* special_function */
  1970. "R_MICROMIPS_LITERAL", /* name */
  1971. TRUE, /* partial_inplace */
  1972. 0x0000ffff, /* src_mask */
  1973. 0x0000ffff, /* dst_mask */
  1974. FALSE), /* pcrel_offset */
  1975. /* Reference to global offset table. */
  1976. HOWTO (R_MICROMIPS_GOT16, /* type */
  1977. 0, /* rightshift */
  1978. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1979. 16, /* bitsize */
  1980. FALSE, /* pc_relative */
  1981. 0, /* bitpos */
  1982. complain_overflow_signed, /* complain_on_overflow */
  1983. _bfd_mips_elf_got16_reloc, /* special_function */
  1984. "R_MICROMIPS_GOT16", /* name */
  1985. TRUE, /* partial_inplace */
  1986. 0x0000ffff, /* src_mask */
  1987. 0x0000ffff, /* dst_mask */
  1988. FALSE), /* pcrel_offset */
  1989. /* This is for microMIPS branches. */
  1990. HOWTO (R_MICROMIPS_PC7_S1, /* type */
  1991. 1, /* rightshift */
  1992. 1, /* size (0 = byte, 1 = short, 2 = long) */
  1993. 7, /* bitsize */
  1994. TRUE, /* pc_relative */
  1995. 0, /* bitpos */
  1996. complain_overflow_signed, /* complain_on_overflow */
  1997. _bfd_mips_elf_generic_reloc, /* special_function */
  1998. "R_MICROMIPS_PC7_S1", /* name */
  1999. TRUE, /* partial_inplace */
  2000. 0x0000007f, /* src_mask */
  2001. 0x0000007f, /* dst_mask */
  2002. TRUE), /* pcrel_offset */
  2003. HOWTO (R_MICROMIPS_PC10_S1, /* type */
  2004. 1, /* rightshift */
  2005. 1, /* size (0 = byte, 1 = short, 2 = long) */
  2006. 10, /* bitsize */
  2007. TRUE, /* pc_relative */
  2008. 0, /* bitpos */
  2009. complain_overflow_signed, /* complain_on_overflow */
  2010. _bfd_mips_elf_generic_reloc, /* special_function */
  2011. "R_MICROMIPS_PC10_S1", /* name */
  2012. TRUE, /* partial_inplace */
  2013. 0x000003ff, /* src_mask */
  2014. 0x000003ff, /* dst_mask */
  2015. TRUE), /* pcrel_offset */
  2016. HOWTO (R_MICROMIPS_PC16_S1, /* type */
  2017. 1, /* rightshift */
  2018. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2019. 16, /* bitsize */
  2020. TRUE, /* pc_relative */
  2021. 0, /* bitpos */
  2022. complain_overflow_signed, /* complain_on_overflow */
  2023. _bfd_mips_elf_generic_reloc, /* special_function */
  2024. "R_MICROMIPS_PC16_S1", /* name */
  2025. TRUE, /* partial_inplace */
  2026. 0x0000ffff, /* src_mask */
  2027. 0x0000ffff, /* dst_mask */
  2028. TRUE), /* pcrel_offset */
  2029. /* 16 bit call through global offset table. */
  2030. HOWTO (R_MICROMIPS_CALL16, /* type */
  2031. 0, /* rightshift */
  2032. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2033. 16, /* bitsize */
  2034. FALSE, /* pc_relative */
  2035. 0, /* bitpos */
  2036. complain_overflow_signed, /* complain_on_overflow */
  2037. _bfd_mips_elf_generic_reloc, /* special_function */
  2038. "R_MICROMIPS_CALL16", /* name */
  2039. TRUE, /* partial_inplace */
  2040. 0x0000ffff, /* src_mask */
  2041. 0x0000ffff, /* dst_mask */
  2042. FALSE), /* pcrel_offset */
  2043. EMPTY_HOWTO (143),
  2044. EMPTY_HOWTO (144),
  2045. /* Displacement in the global offset table. */
  2046. HOWTO (R_MICROMIPS_GOT_DISP, /* type */
  2047. 0, /* rightshift */
  2048. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2049. 16, /* bitsize */
  2050. FALSE, /* pc_relative */
  2051. 0, /* bitpos */
  2052. complain_overflow_signed, /* complain_on_overflow */
  2053. _bfd_mips_elf_generic_reloc, /* special_function */
  2054. "R_MICROMIPS_GOT_DISP",/* name */
  2055. TRUE, /* partial_inplace */
  2056. 0x0000ffff, /* src_mask */
  2057. 0x0000ffff, /* dst_mask */
  2058. FALSE), /* pcrel_offset */
  2059. /* Displacement to page pointer in the global offset table. */
  2060. HOWTO (R_MICROMIPS_GOT_PAGE, /* type */
  2061. 0, /* rightshift */
  2062. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2063. 16, /* bitsize */
  2064. FALSE, /* pc_relative */
  2065. 0, /* bitpos */
  2066. complain_overflow_signed, /* complain_on_overflow */
  2067. _bfd_mips_elf_generic_reloc, /* special_function */
  2068. "R_MICROMIPS_GOT_PAGE",/* name */
  2069. TRUE, /* partial_inplace */
  2070. 0x0000ffff, /* src_mask */
  2071. 0x0000ffff, /* dst_mask */
  2072. FALSE), /* pcrel_offset */
  2073. /* Offset from page pointer in the global offset table. */
  2074. HOWTO (R_MICROMIPS_GOT_OFST, /* type */
  2075. 0, /* rightshift */
  2076. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2077. 16, /* bitsize */
  2078. FALSE, /* pc_relative */
  2079. 0, /* bitpos */
  2080. complain_overflow_signed, /* complain_on_overflow */
  2081. _bfd_mips_elf_generic_reloc, /* special_function */
  2082. "R_MICROMIPS_GOT_OFST",/* name */
  2083. TRUE, /* partial_inplace */
  2084. 0x0000ffff, /* src_mask */
  2085. 0x0000ffff, /* dst_mask */
  2086. FALSE), /* pcrel_offset */
  2087. /* High 16 bits of displacement in global offset table. */
  2088. HOWTO (R_MICROMIPS_GOT_HI16, /* type */
  2089. 0, /* rightshift */
  2090. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2091. 16, /* bitsize */
  2092. FALSE, /* pc_relative */
  2093. 0, /* bitpos */
  2094. complain_overflow_dont, /* complain_on_overflow */
  2095. _bfd_mips_elf_generic_reloc, /* special_function */
  2096. "R_MICROMIPS_GOT_HI16",/* name */
  2097. TRUE, /* partial_inplace */
  2098. 0x0000ffff, /* src_mask */
  2099. 0x0000ffff, /* dst_mask */
  2100. FALSE), /* pcrel_offset */
  2101. /* Low 16 bits of displacement in global offset table. */
  2102. HOWTO (R_MICROMIPS_GOT_LO16, /* type */
  2103. 0, /* rightshift */
  2104. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2105. 16, /* bitsize */
  2106. FALSE, /* pc_relative */
  2107. 0, /* bitpos */
  2108. complain_overflow_dont, /* complain_on_overflow */
  2109. _bfd_mips_elf_generic_reloc, /* special_function */
  2110. "R_MICROMIPS_GOT_LO16",/* name */
  2111. TRUE, /* partial_inplace */
  2112. 0x0000ffff, /* src_mask */
  2113. 0x0000ffff, /* dst_mask */
  2114. FALSE), /* pcrel_offset */
  2115. /* 64 bit subtraction. Used in the N32 ABI. */
  2116. HOWTO (R_MICROMIPS_SUB, /* type */
  2117. 0, /* rightshift */
  2118. 4, /* size (0 = byte, 1 = short, 2 = long) */
  2119. 64, /* bitsize */
  2120. FALSE, /* pc_relative */
  2121. 0, /* bitpos */
  2122. complain_overflow_dont, /* complain_on_overflow */
  2123. _bfd_mips_elf_generic_reloc, /* special_function */
  2124. "R_MICROMIPS_SUB", /* name */
  2125. TRUE, /* partial_inplace */
  2126. MINUS_ONE, /* src_mask */
  2127. MINUS_ONE, /* dst_mask */
  2128. FALSE), /* pcrel_offset */
  2129. /* We don't support these for REL relocations, because it means building
  2130. the addend from a R_MICROMIPS_HIGHEST/R_MICROMIPS_HIGHER/
  2131. R_MICROMIPS_HI16/R_MICROMIPS_LO16 sequence with varying ordering,
  2132. using fallable heuristics. */
  2133. EMPTY_HOWTO (R_MICROMIPS_HIGHER),
  2134. EMPTY_HOWTO (R_MICROMIPS_HIGHEST),
  2135. /* High 16 bits of displacement in global offset table. */
  2136. HOWTO (R_MICROMIPS_CALL_HI16, /* type */
  2137. 0, /* rightshift */
  2138. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2139. 16, /* bitsize */
  2140. FALSE, /* pc_relative */
  2141. 0, /* bitpos */
  2142. complain_overflow_dont, /* complain_on_overflow */
  2143. _bfd_mips_elf_generic_reloc, /* special_function */
  2144. "R_MICROMIPS_CALL_HI16",/* name */
  2145. TRUE, /* partial_inplace */
  2146. 0x0000ffff, /* src_mask */
  2147. 0x0000ffff, /* dst_mask */
  2148. FALSE), /* pcrel_offset */
  2149. /* Low 16 bits of displacement in global offset table. */
  2150. HOWTO (R_MICROMIPS_CALL_LO16, /* type */
  2151. 0, /* rightshift */
  2152. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2153. 16, /* bitsize */
  2154. FALSE, /* pc_relative */
  2155. 0, /* bitpos */
  2156. complain_overflow_dont, /* complain_on_overflow */
  2157. _bfd_mips_elf_generic_reloc, /* special_function */
  2158. "R_MICROMIPS_CALL_LO16",/* name */
  2159. TRUE, /* partial_inplace */
  2160. 0x0000ffff, /* src_mask */
  2161. 0x0000ffff, /* dst_mask */
  2162. FALSE), /* pcrel_offset */
  2163. /* Section displacement. */
  2164. HOWTO (R_MICROMIPS_SCN_DISP, /* type */
  2165. 0, /* rightshift */
  2166. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2167. 32, /* bitsize */
  2168. FALSE, /* pc_relative */
  2169. 0, /* bitpos */
  2170. complain_overflow_dont, /* complain_on_overflow */
  2171. _bfd_mips_elf_generic_reloc, /* special_function */
  2172. "R_MICROMIPS_SCN_DISP", /* name */
  2173. TRUE, /* partial_inplace */
  2174. 0xffffffff, /* src_mask */
  2175. 0xffffffff, /* dst_mask */
  2176. FALSE), /* pcrel_offset */
  2177. /* Protected jump conversion. This is an optimization hint. No
  2178. relocation is required for correctness. */
  2179. HOWTO (R_MICROMIPS_JALR, /* type */
  2180. 0, /* rightshift */
  2181. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2182. 32, /* bitsize */
  2183. FALSE, /* pc_relative */
  2184. 0, /* bitpos */
  2185. complain_overflow_dont, /* complain_on_overflow */
  2186. _bfd_mips_elf_generic_reloc, /* special_function */
  2187. "R_MICROMIPS_JALR", /* name */
  2188. FALSE, /* partial_inplace */
  2189. 0, /* src_mask */
  2190. 0x00000000, /* dst_mask */
  2191. FALSE), /* pcrel_offset */
  2192. };
  2193. static reloc_howto_type elf_micromips_howto_table_rela[] =
  2194. {
  2195. EMPTY_HOWTO (130),
  2196. EMPTY_HOWTO (131),
  2197. EMPTY_HOWTO (132),
  2198. /* 26 bit jump address. */
  2199. HOWTO (R_MICROMIPS_26_S1, /* type */
  2200. 1, /* rightshift */
  2201. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2202. 26, /* bitsize */
  2203. FALSE, /* pc_relative */
  2204. 0, /* bitpos */
  2205. complain_overflow_dont, /* complain_on_overflow */
  2206. /* This needs complex overflow
  2207. detection, because the upper four
  2208. bits must match the PC. */
  2209. _bfd_mips_elf_generic_reloc, /* special_function */
  2210. "R_MICROMIPS_26_S1", /* name */
  2211. FALSE, /* partial_inplace */
  2212. 0, /* src_mask */
  2213. 0x3ffffff, /* dst_mask */
  2214. FALSE), /* pcrel_offset */
  2215. /* High 16 bits of symbol value. */
  2216. HOWTO (R_MICROMIPS_HI16, /* type */
  2217. 16, /* rightshift */
  2218. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2219. 16, /* bitsize */
  2220. FALSE, /* pc_relative */
  2221. 0, /* bitpos */
  2222. complain_overflow_dont, /* complain_on_overflow */
  2223. _bfd_mips_elf_hi16_reloc, /* special_function */
  2224. "R_MICROMIPS_HI16", /* name */
  2225. FALSE, /* partial_inplace */
  2226. 0, /* src_mask */
  2227. 0x0000ffff, /* dst_mask */
  2228. FALSE), /* pcrel_offset */
  2229. /* Low 16 bits of symbol value. */
  2230. HOWTO (R_MICROMIPS_LO16, /* type */
  2231. 0, /* rightshift */
  2232. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2233. 16, /* bitsize */
  2234. FALSE, /* pc_relative */
  2235. 0, /* bitpos */
  2236. complain_overflow_dont, /* complain_on_overflow */
  2237. _bfd_mips_elf_lo16_reloc, /* special_function */
  2238. "R_MICROMIPS_LO16", /* name */
  2239. FALSE, /* partial_inplace */
  2240. 0, /* src_mask */
  2241. 0x0000ffff, /* dst_mask */
  2242. FALSE), /* pcrel_offset */
  2243. /* GP relative reference. */
  2244. HOWTO (R_MICROMIPS_GPREL16, /* type */
  2245. 0, /* rightshift */
  2246. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2247. 16, /* bitsize */
  2248. FALSE, /* pc_relative */
  2249. 0, /* bitpos */
  2250. complain_overflow_signed, /* complain_on_overflow */
  2251. _bfd_mips_elf32_gprel16_reloc, /* special_function */
  2252. "R_MICROMIPS_GPREL16", /* name */
  2253. FALSE, /* partial_inplace */
  2254. 0, /* src_mask */
  2255. 0x0000ffff, /* dst_mask */
  2256. FALSE), /* pcrel_offset */
  2257. /* Reference to literal section. */
  2258. HOWTO (R_MICROMIPS_LITERAL, /* type */
  2259. 0, /* rightshift */
  2260. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2261. 16, /* bitsize */
  2262. FALSE, /* pc_relative */
  2263. 0, /* bitpos */
  2264. complain_overflow_signed, /* complain_on_overflow */
  2265. _bfd_mips_elf32_gprel16_reloc, /* special_function */
  2266. "R_MICROMIPS_LITERAL", /* name */
  2267. FALSE, /* partial_inplace */
  2268. 0, /* src_mask */
  2269. 0x0000ffff, /* dst_mask */
  2270. FALSE), /* pcrel_offset */
  2271. /* Reference to global offset table. */
  2272. HOWTO (R_MICROMIPS_GOT16, /* type */
  2273. 0, /* rightshift */
  2274. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2275. 16, /* bitsize */
  2276. FALSE, /* pc_relative */
  2277. 0, /* bitpos */
  2278. complain_overflow_signed, /* complain_on_overflow */
  2279. _bfd_mips_elf_got16_reloc, /* special_function */
  2280. "R_MICROMIPS_GOT16", /* name */
  2281. FALSE, /* partial_inplace */
  2282. 0, /* src_mask */
  2283. 0x0000ffff, /* dst_mask */
  2284. FALSE), /* pcrel_offset */
  2285. /* This is for microMIPS branches. */
  2286. HOWTO (R_MICROMIPS_PC7_S1, /* type */
  2287. 1, /* rightshift */
  2288. 1, /* size (0 = byte, 1 = short, 2 = long) */
  2289. 7, /* bitsize */
  2290. TRUE, /* pc_relative */
  2291. 0, /* bitpos */
  2292. complain_overflow_signed, /* complain_on_overflow */
  2293. _bfd_mips_elf_generic_reloc, /* special_function */
  2294. "R_MICROMIPS_PC7_S1", /* name */
  2295. FALSE, /* partial_inplace */
  2296. 0, /* src_mask */
  2297. 0x0000007f, /* dst_mask */
  2298. TRUE), /* pcrel_offset */
  2299. HOWTO (R_MICROMIPS_PC10_S1, /* type */
  2300. 1, /* rightshift */
  2301. 1, /* size (0 = byte, 1 = short, 2 = long) */
  2302. 10, /* bitsize */
  2303. TRUE, /* pc_relative */
  2304. 0, /* bitpos */
  2305. complain_overflow_signed, /* complain_on_overflow */
  2306. _bfd_mips_elf_generic_reloc, /* special_function */
  2307. "R_MICROMIPS_PC10_S1", /* name */
  2308. FALSE, /* partial_inplace */
  2309. 0, /* src_mask */
  2310. 0x000003ff, /* dst_mask */
  2311. TRUE), /* pcrel_offset */
  2312. HOWTO (R_MICROMIPS_PC16_S1, /* type */
  2313. 1, /* rightshift */
  2314. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2315. 16, /* bitsize */
  2316. TRUE, /* pc_relative */
  2317. 0, /* bitpos */
  2318. complain_overflow_signed, /* complain_on_overflow */
  2319. _bfd_mips_elf_generic_reloc, /* special_function */
  2320. "R_MICROMIPS_PC16_S1", /* name */
  2321. FALSE, /* partial_inplace */
  2322. 0, /* src_mask */
  2323. 0x0000ffff, /* dst_mask */
  2324. TRUE), /* pcrel_offset */
  2325. /* 16 bit call through global offset table. */
  2326. HOWTO (R_MICROMIPS_CALL16, /* type */
  2327. 0, /* rightshift */
  2328. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2329. 16, /* bitsize */
  2330. FALSE, /* pc_relative */
  2331. 0, /* bitpos */
  2332. complain_overflow_signed, /* complain_on_overflow */
  2333. _bfd_mips_elf_generic_reloc, /* special_function */
  2334. "R_MICROMIPS_CALL16", /* name */
  2335. FALSE, /* partial_inplace */
  2336. 0, /* src_mask */
  2337. 0x0000ffff, /* dst_mask */
  2338. FALSE), /* pcrel_offset */
  2339. EMPTY_HOWTO (143),
  2340. EMPTY_HOWTO (144),
  2341. /* Displacement in the global offset table. */
  2342. HOWTO (R_MICROMIPS_GOT_DISP, /* type */
  2343. 0, /* rightshift */
  2344. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2345. 16, /* bitsize */
  2346. FALSE, /* pc_relative */
  2347. 0, /* bitpos */
  2348. complain_overflow_signed, /* complain_on_overflow */
  2349. _bfd_mips_elf_generic_reloc, /* special_function */
  2350. "R_MICROMIPS_GOT_DISP",/* name */
  2351. FALSE, /* partial_inplace */
  2352. 0, /* src_mask */
  2353. 0x0000ffff, /* dst_mask */
  2354. FALSE), /* pcrel_offset */
  2355. /* Displacement to page pointer in the global offset table. */
  2356. HOWTO (R_MICROMIPS_GOT_PAGE, /* type */
  2357. 0, /* rightshift */
  2358. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2359. 16, /* bitsize */
  2360. FALSE, /* pc_relative */
  2361. 0, /* bitpos */
  2362. complain_overflow_signed, /* complain_on_overflow */
  2363. _bfd_mips_elf_generic_reloc, /* special_function */
  2364. "R_MICROMIPS_GOT_PAGE",/* name */
  2365. FALSE, /* partial_inplace */
  2366. 0, /* src_mask */
  2367. 0x0000ffff, /* dst_mask */
  2368. FALSE), /* pcrel_offset */
  2369. /* Offset from page pointer in the global offset table. */
  2370. HOWTO (R_MICROMIPS_GOT_OFST, /* type */
  2371. 0, /* rightshift */
  2372. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2373. 16, /* bitsize */
  2374. FALSE, /* pc_relative */
  2375. 0, /* bitpos */
  2376. complain_overflow_signed, /* complain_on_overflow */
  2377. _bfd_mips_elf_generic_reloc, /* special_function */
  2378. "R_MICROMIPS_GOT_OFST",/* name */
  2379. FALSE, /* partial_inplace */
  2380. 0, /* src_mask */
  2381. 0x0000ffff, /* dst_mask */
  2382. FALSE), /* pcrel_offset */
  2383. /* High 16 bits of displacement in global offset table. */
  2384. HOWTO (R_MICROMIPS_GOT_HI16, /* type */
  2385. 0, /* rightshift */
  2386. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2387. 16, /* bitsize */
  2388. FALSE, /* pc_relative */
  2389. 0, /* bitpos */
  2390. complain_overflow_dont, /* complain_on_overflow */
  2391. _bfd_mips_elf_generic_reloc, /* special_function */
  2392. "R_MICROMIPS_GOT_HI16",/* name */
  2393. FALSE, /* partial_inplace */
  2394. 0, /* src_mask */
  2395. 0x0000ffff, /* dst_mask */
  2396. FALSE), /* pcrel_offset */
  2397. /* Low 16 bits of displacement in global offset table. */
  2398. HOWTO (R_MICROMIPS_GOT_LO16, /* type */
  2399. 0, /* rightshift */
  2400. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2401. 16, /* bitsize */
  2402. FALSE, /* pc_relative */
  2403. 0, /* bitpos */
  2404. complain_overflow_dont, /* complain_on_overflow */
  2405. _bfd_mips_elf_generic_reloc, /* special_function */
  2406. "R_MICROMIPS_GOT_LO16",/* name */
  2407. FALSE, /* partial_inplace */
  2408. 0, /* src_mask */
  2409. 0x0000ffff, /* dst_mask */
  2410. FALSE), /* pcrel_offset */
  2411. /* 64 bit subtraction. Used in the N32 ABI. */
  2412. HOWTO (R_MICROMIPS_SUB, /* type */
  2413. 0, /* rightshift */
  2414. 4, /* size (0 = byte, 1 = short, 2 = long) */
  2415. 64, /* bitsize */
  2416. FALSE, /* pc_relative */
  2417. 0, /* bitpos */
  2418. complain_overflow_dont, /* complain_on_overflow */
  2419. _bfd_mips_elf_generic_reloc, /* special_function */
  2420. "R_MICROMIPS_SUB", /* name */
  2421. FALSE, /* partial_inplace */
  2422. 0, /* src_mask */
  2423. MINUS_ONE, /* dst_mask */
  2424. FALSE), /* pcrel_offset */
  2425. /* Get the higher value of a 64 bit addend. */
  2426. HOWTO (R_MICROMIPS_HIGHER, /* type */
  2427. 0, /* rightshift */
  2428. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2429. 16, /* bitsize */
  2430. FALSE, /* pc_relative */
  2431. 0, /* bitpos */
  2432. complain_overflow_dont, /* complain_on_overflow */
  2433. _bfd_mips_elf_generic_reloc, /* special_function */
  2434. "R_MICROMIPS_HIGHER", /* name */
  2435. FALSE, /* partial_inplace */
  2436. 0, /* src_mask */
  2437. 0x0000ffff, /* dst_mask */
  2438. FALSE), /* pcrel_offset */
  2439. /* Get the highest value of a 64 bit addend. */
  2440. HOWTO (R_MICROMIPS_HIGHEST, /* type */
  2441. 0, /* rightshift */
  2442. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2443. 16, /* bitsize */
  2444. FALSE, /* pc_relative */
  2445. 0, /* bitpos */
  2446. complain_overflow_dont, /* complain_on_overflow */
  2447. _bfd_mips_elf_generic_reloc, /* special_function */
  2448. "R_MICROMIPS_HIGHEST", /* name */
  2449. FALSE, /* partial_inplace */
  2450. 0, /* src_mask */
  2451. 0x0000ffff, /* dst_mask */
  2452. FALSE), /* pcrel_offset */
  2453. /* High 16 bits of displacement in global offset table. */
  2454. HOWTO (R_MICROMIPS_CALL_HI16, /* type */
  2455. 0, /* rightshift */
  2456. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2457. 16, /* bitsize */
  2458. FALSE, /* pc_relative */
  2459. 0, /* bitpos */
  2460. complain_overflow_dont, /* complain_on_overflow */
  2461. _bfd_mips_elf_generic_reloc, /* special_function */
  2462. "R_MICROMIPS_CALL_HI16",/* name */
  2463. FALSE, /* partial_inplace */
  2464. 0, /* src_mask */
  2465. 0x0000ffff, /* dst_mask */
  2466. FALSE), /* pcrel_offset */
  2467. /* Low 16 bits of displacement in global offset table. */
  2468. HOWTO (R_MICROMIPS_CALL_LO16, /* type */
  2469. 0, /* rightshift */
  2470. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2471. 16, /* bitsize */
  2472. FALSE, /* pc_relative */
  2473. 0, /* bitpos */
  2474. complain_overflow_dont, /* complain_on_overflow */
  2475. _bfd_mips_elf_generic_reloc, /* special_function */
  2476. "R_MICROMIPS_CALL_LO16",/* name */
  2477. FALSE, /* partial_inplace */
  2478. 0, /* src_mask */
  2479. 0x0000ffff, /* dst_mask */
  2480. FALSE), /* pcrel_offset */
  2481. /* Section displacement. */
  2482. HOWTO (R_MICROMIPS_SCN_DISP, /* type */
  2483. 0, /* rightshift */
  2484. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2485. 32, /* bitsize */
  2486. FALSE, /* pc_relative */
  2487. 0, /* bitpos */
  2488. complain_overflow_dont, /* complain_on_overflow */
  2489. _bfd_mips_elf_generic_reloc, /* special_function */
  2490. "R_MICROMIPS_SCN_DISP", /* name */
  2491. FALSE, /* partial_inplace */
  2492. 0, /* src_mask */
  2493. 0xffffffff, /* dst_mask */
  2494. FALSE), /* pcrel_offset */
  2495. /* Protected jump conversion. This is an optimization hint. No
  2496. relocation is required for correctness. */
  2497. HOWTO (R_MICROMIPS_JALR, /* type */
  2498. 0, /* rightshift */
  2499. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2500. 32, /* bitsize */
  2501. FALSE, /* pc_relative */
  2502. 0, /* bitpos */
  2503. complain_overflow_dont, /* complain_on_overflow */
  2504. _bfd_mips_elf_generic_reloc, /* special_function */
  2505. "R_MICROMIPS_JALR", /* name */
  2506. FALSE, /* partial_inplace */
  2507. 0, /* src_mask */
  2508. 0x00000000, /* dst_mask */
  2509. FALSE), /* pcrel_offset */
  2510. };
  2511. /* GNU extension to record C++ vtable hierarchy */
  2512. static reloc_howto_type elf_mips_gnu_vtinherit_howto =
  2513. HOWTO (R_MIPS_GNU_VTINHERIT, /* type */
  2514. 0, /* rightshift */
  2515. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2516. 0, /* bitsize */
  2517. FALSE, /* pc_relative */
  2518. 0, /* bitpos */
  2519. complain_overflow_dont, /* complain_on_overflow */
  2520. NULL, /* special_function */
  2521. "R_MIPS_GNU_VTINHERIT", /* name */
  2522. FALSE, /* partial_inplace */
  2523. 0, /* src_mask */
  2524. 0, /* dst_mask */
  2525. FALSE); /* pcrel_offset */
  2526. /* GNU extension to record C++ vtable member usage */
  2527. static reloc_howto_type elf_mips_gnu_vtentry_howto =
  2528. HOWTO (R_MIPS_GNU_VTENTRY, /* type */
  2529. 0, /* rightshift */
  2530. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2531. 0, /* bitsize */
  2532. FALSE, /* pc_relative */
  2533. 0, /* bitpos */
  2534. complain_overflow_dont, /* complain_on_overflow */
  2535. _bfd_elf_rel_vtable_reloc_fn, /* special_function */
  2536. "R_MIPS_GNU_VTENTRY", /* name */
  2537. FALSE, /* partial_inplace */
  2538. 0, /* src_mask */
  2539. 0, /* dst_mask */
  2540. FALSE); /* pcrel_offset */
  2541. /* 16 bit offset for pc-relative branches. */
  2542. static reloc_howto_type elf_mips_gnu_rel16_s2 =
  2543. HOWTO (R_MIPS_GNU_REL16_S2, /* type */
  2544. 2, /* rightshift */
  2545. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2546. 16, /* bitsize */
  2547. TRUE, /* pc_relative */
  2548. 0, /* bitpos */
  2549. complain_overflow_signed, /* complain_on_overflow */
  2550. _bfd_mips_elf_generic_reloc, /* special_function */
  2551. "R_MIPS_GNU_REL16_S2", /* name */
  2552. TRUE, /* partial_inplace */
  2553. 0x0000ffff, /* src_mask */
  2554. 0x0000ffff, /* dst_mask */
  2555. TRUE); /* pcrel_offset */
  2556. /* 16 bit offset for pc-relative branches. */
  2557. static reloc_howto_type elf_mips_gnu_rela16_s2 =
  2558. HOWTO (R_MIPS_GNU_REL16_S2, /* type */
  2559. 2, /* rightshift */
  2560. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2561. 16, /* bitsize */
  2562. TRUE, /* pc_relative */
  2563. 0, /* bitpos */
  2564. complain_overflow_signed, /* complain_on_overflow */
  2565. _bfd_mips_elf_generic_reloc, /* special_function */
  2566. "R_MIPS_GNU_REL16_S2", /* name */
  2567. FALSE, /* partial_inplace */
  2568. 0, /* src_mask */
  2569. 0x0000ffff, /* dst_mask */
  2570. TRUE); /* pcrel_offset */
  2571. /* 32 bit pc-relative. Used for compact EH tables. */
  2572. static reloc_howto_type elf_mips_gnu_pcrel32 =
  2573. HOWTO (R_MIPS_PC32, /* type */
  2574. 0, /* rightshift */
  2575. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2576. 32, /* bitsize */
  2577. TRUE, /* pc_relative */
  2578. 0, /* bitpos */
  2579. complain_overflow_signed, /* complain_on_overflow */
  2580. _bfd_mips_elf_generic_reloc, /* special_function */
  2581. "R_MIPS_PC32", /* name */
  2582. TRUE, /* partial_inplace */
  2583. 0xffffffff, /* src_mask */
  2584. 0xffffffff, /* dst_mask */
  2585. TRUE); /* pcrel_offset */
  2586. /* Originally a VxWorks extension, but now used for other systems too. */
  2587. static reloc_howto_type elf_mips_copy_howto =
  2588. HOWTO (R_MIPS_COPY, /* type */
  2589. 0, /* rightshift */
  2590. 0, /* this one is variable size */
  2591. 0, /* bitsize */
  2592. FALSE, /* pc_relative */
  2593. 0, /* bitpos */
  2594. complain_overflow_bitfield, /* complain_on_overflow */
  2595. _bfd_mips_elf_generic_reloc, /* special_function */
  2596. "R_MIPS_COPY", /* name */
  2597. FALSE, /* partial_inplace */
  2598. 0x0, /* src_mask */
  2599. 0x0, /* dst_mask */
  2600. FALSE); /* pcrel_offset */
  2601. /* Originally a VxWorks extension, but now used for other systems too. */
  2602. static reloc_howto_type elf_mips_jump_slot_howto =
  2603. HOWTO (R_MIPS_JUMP_SLOT, /* type */
  2604. 0, /* rightshift */
  2605. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2606. 32, /* bitsize */
  2607. FALSE, /* pc_relative */
  2608. 0, /* bitpos */
  2609. complain_overflow_bitfield, /* complain_on_overflow */
  2610. _bfd_mips_elf_generic_reloc, /* special_function */
  2611. "R_MIPS_JUMP_SLOT", /* name */
  2612. FALSE, /* partial_inplace */
  2613. 0x0, /* src_mask */
  2614. 0x0, /* dst_mask */
  2615. FALSE); /* pcrel_offset */
  2616. /* Used in EH tables. */
  2617. static reloc_howto_type elf_mips_eh_howto =
  2618. HOWTO (R_MIPS_EH, /* type */
  2619. 0, /* rightshift */
  2620. 2, /* size (0 = byte, 1 = short, 2 = long) */
  2621. 32, /* bitsize */
  2622. FALSE, /* pc_relative */
  2623. 0, /* bitpos */
  2624. complain_overflow_signed, /* complain_on_overflow */
  2625. _bfd_mips_elf_generic_reloc, /* special_function */
  2626. "R_MIPS_EH", /* name */
  2627. TRUE, /* partial_inplace */
  2628. 0xffffffff, /* src_mask */
  2629. 0xffffffff, /* dst_mask */
  2630. FALSE); /* pcrel_offset */
  2631. /* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
  2632. dangerous relocation. */
  2633. static bfd_boolean
  2634. mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
  2635. {
  2636. unsigned int count;
  2637. asymbol **sym;
  2638. unsigned int i;
  2639. /* If we've already figured out what GP will be, just return it. */
  2640. *pgp = _bfd_get_gp_value (output_bfd);
  2641. if (*pgp)
  2642. return TRUE;
  2643. count = bfd_get_symcount (output_bfd);
  2644. sym = bfd_get_outsymbols (output_bfd);
  2645. /* The linker script will have created a symbol named `_gp' with the
  2646. appropriate value. */
  2647. if (sym == NULL)
  2648. i = count;
  2649. else
  2650. {
  2651. for (i = 0; i < count; i++, sym++)
  2652. {
  2653. register const char *name;
  2654. name = bfd_asymbol_name (*sym);
  2655. if (*name == '_' && strcmp (name, "_gp") == 0)
  2656. {
  2657. *pgp = bfd_asymbol_value (*sym);
  2658. _bfd_set_gp_value (output_bfd, *pgp);
  2659. break;
  2660. }
  2661. }
  2662. }
  2663. if (i >= count)
  2664. {
  2665. /* Only get the error once. */
  2666. *pgp = 4;
  2667. _bfd_set_gp_value (output_bfd, *pgp);
  2668. return FALSE;
  2669. }
  2670. return TRUE;
  2671. }
  2672. /* We have to figure out the gp value, so that we can adjust the
  2673. symbol value correctly. We look up the symbol _gp in the output
  2674. BFD. If we can't find it, we're stuck. We cache it in the ELF
  2675. target data. We don't need to adjust the symbol value for an
  2676. external symbol if we are producing relocatable output. */
  2677. static bfd_reloc_status_type
  2678. mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
  2679. char **error_message, bfd_vma *pgp)
  2680. {
  2681. if (bfd_is_und_section (symbol->section)
  2682. && ! relocatable)
  2683. {
  2684. *pgp = 0;
  2685. return bfd_reloc_undefined;
  2686. }
  2687. *pgp = _bfd_get_gp_value (output_bfd);
  2688. if (*pgp == 0
  2689. && (! relocatable
  2690. || (symbol->flags & BSF_SECTION_SYM) != 0))
  2691. {
  2692. if (relocatable)
  2693. {
  2694. /* Make up a value. */
  2695. *pgp = symbol->section->output_section->vma /*+ 0x4000*/;
  2696. _bfd_set_gp_value (output_bfd, *pgp);
  2697. }
  2698. else if (!mips_elf_assign_gp (output_bfd, pgp))
  2699. {
  2700. *error_message =
  2701. (char *) _("GP relative relocation when _gp not defined");
  2702. return bfd_reloc_dangerous;
  2703. }
  2704. }
  2705. return bfd_reloc_ok;
  2706. }
  2707. /* Do a R_MIPS_GPREL16 relocation. This is a 16 bit value which must
  2708. become the offset from the gp register. */
  2709. static bfd_reloc_status_type
  2710. mips_elf_gprel16_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
  2711. asymbol *symbol, void *data ATTRIBUTE_UNUSED,
  2712. asection *input_section, bfd *output_bfd,
  2713. char **error_message ATTRIBUTE_UNUSED)
  2714. {
  2715. bfd_boolean relocatable;
  2716. bfd_reloc_status_type ret;
  2717. bfd_vma gp;
  2718. if (output_bfd != NULL)
  2719. relocatable = TRUE;
  2720. else
  2721. {
  2722. relocatable = FALSE;
  2723. output_bfd = symbol->section->output_section->owner;
  2724. }
  2725. ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
  2726. &gp);
  2727. if (ret != bfd_reloc_ok)
  2728. return ret;
  2729. return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
  2730. input_section, relocatable,
  2731. data, gp);
  2732. }
  2733. /* Do a R_MIPS_LITERAL relocation. */
  2734. static bfd_reloc_status_type
  2735. mips_elf_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
  2736. void *data, asection *input_section, bfd *output_bfd,
  2737. char **error_message)
  2738. {
  2739. bfd_boolean relocatable;
  2740. bfd_reloc_status_type ret;
  2741. bfd_vma gp;
  2742. /* R_MIPS_LITERAL relocations are defined for local symbols only. */
  2743. if (output_bfd != NULL
  2744. && (symbol->flags & BSF_SECTION_SYM) == 0
  2745. && (symbol->flags & BSF_LOCAL) != 0)
  2746. {
  2747. *error_message = (char *)
  2748. _("literal relocation occurs for an external symbol");
  2749. return bfd_reloc_outofrange;
  2750. }
  2751. /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */
  2752. if (output_bfd != NULL)
  2753. relocatable = TRUE;
  2754. else
  2755. {
  2756. relocatable = FALSE;
  2757. output_bfd = symbol->section->output_section->owner;
  2758. }
  2759. ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
  2760. &gp);
  2761. if (ret != bfd_reloc_ok)
  2762. return ret;
  2763. return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
  2764. input_section, relocatable,
  2765. data, gp);
  2766. }
  2767. /* Do a R_MIPS_GPREL32 relocation. This is a 32 bit value which must
  2768. become the offset from the gp register. */
  2769. static bfd_reloc_status_type
  2770. mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
  2771. void *data, asection *input_section, bfd *output_bfd,
  2772. char **error_message)
  2773. {
  2774. bfd_boolean relocatable;
  2775. bfd_reloc_status_type ret;
  2776. bfd_vma gp;
  2777. /* R_MIPS_GPREL32 relocations are defined for local symbols only. */
  2778. if (output_bfd != NULL
  2779. && (symbol->flags & BSF_SECTION_SYM) == 0
  2780. && (symbol->flags & BSF_LOCAL) != 0)
  2781. {
  2782. *error_message = (char *)
  2783. _("32bits gp relative relocation occurs for an external symbol");
  2784. return bfd_reloc_outofrange;
  2785. }
  2786. if (output_bfd != NULL)
  2787. {
  2788. relocatable = TRUE;
  2789. gp = _bfd_get_gp_value (output_bfd);
  2790. }
  2791. else
  2792. {
  2793. relocatable = FALSE;
  2794. output_bfd = symbol->section->output_section->owner;
  2795. ret = mips_elf_final_gp (output_bfd, symbol, relocatable,
  2796. error_message, &gp);
  2797. if (ret != bfd_reloc_ok)
  2798. return ret;
  2799. }
  2800. return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
  2801. relocatable, data, gp);
  2802. }
  2803. static bfd_reloc_status_type
  2804. gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
  2805. asection *input_section, bfd_boolean relocatable,
  2806. void *data, bfd_vma gp)
  2807. {
  2808. bfd_vma relocation;
  2809. unsigned long val;
  2810. if (bfd_is_com_section (symbol->section))
  2811. relocation = 0;
  2812. else
  2813. relocation = symbol->value;
  2814. relocation += symbol->section->output_section->vma;
  2815. relocation += symbol->section->output_offset;
  2816. if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
  2817. return bfd_reloc_outofrange;
  2818. if (reloc_entry->howto->src_mask == 0)
  2819. val = 0;
  2820. else
  2821. val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
  2822. /* Set val to the offset into the section or symbol. */
  2823. val += reloc_entry->addend;
  2824. /* Adjust val for the final section location and GP value. If we
  2825. are producing relocatable output, we don't want to do this for
  2826. an external symbol. */
  2827. if (! relocatable
  2828. || (symbol->flags & BSF_SECTION_SYM) != 0)
  2829. val += relocation - gp;
  2830. bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
  2831. if (relocatable)
  2832. reloc_entry->address += input_section->output_offset;
  2833. return bfd_reloc_ok;
  2834. }
  2835. /* Do a R_MIPS_SHIFT6 relocation. The MSB of the shift is stored at bit 2,
  2836. the rest is at bits 6-10. The bitpos already got right by the howto. */
  2837. static bfd_reloc_status_type
  2838. mips_elf_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
  2839. void *data, asection *input_section, bfd *output_bfd,
  2840. char **error_message)
  2841. {
  2842. if (reloc_entry->howto->partial_inplace)
  2843. {
  2844. reloc_entry->addend = ((reloc_entry->addend & 0x00007c0)
  2845. | (reloc_entry->addend & 0x00000800) >> 9);
  2846. }
  2847. return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
  2848. input_section, output_bfd,
  2849. error_message);
  2850. }
  2851. /* Handle a mips16 GP relative reloc. */
  2852. static bfd_reloc_status_type
  2853. mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
  2854. void *data, asection *input_section, bfd *output_bfd,
  2855. char **error_message)
  2856. {
  2857. bfd_boolean relocatable;
  2858. bfd_reloc_status_type ret;
  2859. bfd_byte *location;
  2860. bfd_vma gp;
  2861. /* If we're relocating, and this is an external symbol, we don't want
  2862. to change anything. */
  2863. if (output_bfd != NULL
  2864. && (symbol->flags & BSF_SECTION_SYM) == 0
  2865. && (symbol->flags & BSF_LOCAL) != 0)
  2866. {
  2867. reloc_entry->address += input_section->output_offset;
  2868. return bfd_reloc_ok;
  2869. }
  2870. if (output_bfd != NULL)
  2871. relocatable = TRUE;
  2872. else
  2873. {
  2874. relocatable = FALSE;
  2875. output_bfd = symbol->section->output_section->owner;
  2876. }
  2877. ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
  2878. &gp);
  2879. if (ret != bfd_reloc_ok)
  2880. return ret;
  2881. location = (bfd_byte *) data + reloc_entry->address;
  2882. _bfd_mips_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
  2883. location);
  2884. ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
  2885. input_section, relocatable,
  2886. data, gp);
  2887. _bfd_mips_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
  2888. location);
  2889. return ret;
  2890. }
  2891. /* A mapping from BFD reloc types to MIPS ELF reloc types. */
  2892. struct elf_reloc_map {
  2893. bfd_reloc_code_real_type bfd_val;
  2894. enum elf_mips_reloc_type elf_val;
  2895. };
  2896. static const struct elf_reloc_map mips_reloc_map[] =
  2897. {
  2898. { BFD_RELOC_NONE, R_MIPS_NONE },
  2899. { BFD_RELOC_16, R_MIPS_16 },
  2900. { BFD_RELOC_32, R_MIPS_32 },
  2901. /* There is no BFD reloc for R_MIPS_REL32. */
  2902. { BFD_RELOC_CTOR, R_MIPS_32 },
  2903. { BFD_RELOC_64, R_MIPS_64 },
  2904. { BFD_RELOC_16_PCREL_S2, R_MIPS_PC16 },
  2905. { BFD_RELOC_HI16_S, R_MIPS_HI16 },
  2906. { BFD_RELOC_LO16, R_MIPS_LO16 },
  2907. { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
  2908. { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
  2909. { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
  2910. { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
  2911. { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
  2912. { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
  2913. { BFD_RELOC_MIPS_SHIFT5, R_MIPS_SHIFT5 },
  2914. { BFD_RELOC_MIPS_SHIFT6, R_MIPS_SHIFT6 },
  2915. { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
  2916. { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
  2917. { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
  2918. { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
  2919. { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
  2920. { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
  2921. { BFD_RELOC_MIPS_INSERT_A, R_MIPS_INSERT_A },
  2922. { BFD_RELOC_MIPS_INSERT_B, R_MIPS_INSERT_B },
  2923. { BFD_RELOC_MIPS_DELETE, R_MIPS_DELETE },
  2924. { BFD_RELOC_MIPS_HIGHEST, R_MIPS_HIGHEST },
  2925. { BFD_RELOC_MIPS_HIGHER, R_MIPS_HIGHER },
  2926. { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
  2927. { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
  2928. { BFD_RELOC_MIPS_SCN_DISP, R_MIPS_SCN_DISP },
  2929. { BFD_RELOC_MIPS_REL16, R_MIPS_REL16 },
  2930. /* Use of R_MIPS_ADD_IMMEDIATE and R_MIPS_PJUMP is deprecated. */
  2931. { BFD_RELOC_MIPS_RELGOT, R_MIPS_RELGOT },
  2932. { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
  2933. { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
  2934. { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
  2935. { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
  2936. { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
  2937. { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
  2938. { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
  2939. { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
  2940. { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
  2941. { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
  2942. { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
  2943. { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
  2944. { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
  2945. { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 },
  2946. { BFD_RELOC_MIPS_21_PCREL_S2, R_MIPS_PC21_S2 },
  2947. { BFD_RELOC_MIPS_26_PCREL_S2, R_MIPS_PC26_S2 },
  2948. { BFD_RELOC_MIPS_18_PCREL_S3, R_MIPS_PC18_S3 },
  2949. { BFD_RELOC_MIPS_19_PCREL_S2, R_MIPS_PC19_S2 },
  2950. { BFD_RELOC_HI16_S_PCREL, R_MIPS_PCHI16 },
  2951. { BFD_RELOC_LO16_PCREL, R_MIPS_PCLO16 }
  2952. };
  2953. static const struct elf_reloc_map mips16_reloc_map[] =
  2954. {
  2955. { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
  2956. { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
  2957. { BFD_RELOC_MIPS16_GOT16, R_MIPS16_GOT16 - R_MIPS16_min },
  2958. { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
  2959. { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
  2960. { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
  2961. { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min },
  2962. { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min },
  2963. { BFD_RELOC_MIPS16_TLS_DTPREL_HI16,
  2964. R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min },
  2965. { BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
  2966. R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min },
  2967. { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min },
  2968. { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min },
  2969. { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min }
  2970. };
  2971. static const struct elf_reloc_map micromips_reloc_map[] =
  2972. {
  2973. { BFD_RELOC_MICROMIPS_JMP, R_MICROMIPS_26_S1 - R_MICROMIPS_min },
  2974. { BFD_RELOC_MICROMIPS_HI16_S, R_MICROMIPS_HI16 - R_MICROMIPS_min },
  2975. { BFD_RELOC_MICROMIPS_LO16, R_MICROMIPS_LO16 - R_MICROMIPS_min },
  2976. { BFD_RELOC_MICROMIPS_GPREL16, R_MICROMIPS_GPREL16 - R_MICROMIPS_min },
  2977. { BFD_RELOC_MICROMIPS_LITERAL, R_MICROMIPS_LITERAL - R_MICROMIPS_min },
  2978. { BFD_RELOC_MICROMIPS_GOT16, R_MICROMIPS_GOT16 - R_MICROMIPS_min },
  2979. { BFD_RELOC_MICROMIPS_7_PCREL_S1, R_MICROMIPS_PC7_S1 - R_MICROMIPS_min },
  2980. { BFD_RELOC_MICROMIPS_10_PCREL_S1, R_MICROMIPS_PC10_S1 - R_MICROMIPS_min },
  2981. { BFD_RELOC_MICROMIPS_16_PCREL_S1, R_MICROMIPS_PC16_S1 - R_MICROMIPS_min },
  2982. { BFD_RELOC_MICROMIPS_CALL16, R_MICROMIPS_CALL16 - R_MICROMIPS_min },
  2983. { BFD_RELOC_MICROMIPS_GOT_DISP, R_MICROMIPS_GOT_DISP - R_MICROMIPS_min },
  2984. { BFD_RELOC_MICROMIPS_GOT_PAGE, R_MICROMIPS_GOT_PAGE - R_MICROMIPS_min },
  2985. { BFD_RELOC_MICROMIPS_GOT_OFST, R_MICROMIPS_GOT_OFST - R_MICROMIPS_min },
  2986. { BFD_RELOC_MICROMIPS_GOT_HI16, R_MICROMIPS_GOT_HI16 - R_MICROMIPS_min },
  2987. { BFD_RELOC_MICROMIPS_GOT_LO16, R_MICROMIPS_GOT_LO16 - R_MICROMIPS_min },
  2988. { BFD_RELOC_MICROMIPS_SUB, R_MICROMIPS_SUB - R_MICROMIPS_min },
  2989. { BFD_RELOC_MICROMIPS_HIGHER, R_MICROMIPS_HIGHER - R_MICROMIPS_min },
  2990. { BFD_RELOC_MICROMIPS_HIGHEST, R_MICROMIPS_HIGHEST - R_MICROMIPS_min },
  2991. { BFD_RELOC_MICROMIPS_CALL_HI16, R_MICROMIPS_CALL_HI16 - R_MICROMIPS_min },
  2992. { BFD_RELOC_MICROMIPS_CALL_LO16, R_MICROMIPS_CALL_LO16 - R_MICROMIPS_min },
  2993. { BFD_RELOC_MICROMIPS_SCN_DISP, R_MICROMIPS_SCN_DISP - R_MICROMIPS_min },
  2994. { BFD_RELOC_MICROMIPS_JALR, R_MICROMIPS_JALR - R_MICROMIPS_min },
  2995. };
  2996. /* Given a BFD reloc type, return a howto structure. */
  2997. static reloc_howto_type *
  2998. bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
  2999. bfd_reloc_code_real_type code)
  3000. {
  3001. unsigned int i;
  3002. /* FIXME: We default to RELA here instead of choosing the right
  3003. relocation variant. */
  3004. reloc_howto_type *howto_table = elf_mips_howto_table_rela;
  3005. reloc_howto_type *howto16_table = elf_mips16_howto_table_rela;
  3006. reloc_howto_type *howto_micromips_table = elf_micromips_howto_table_rela;
  3007. for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
  3008. i++)
  3009. {
  3010. if (mips_reloc_map[i].bfd_val == code)
  3011. return &howto_table[(int) mips_reloc_map[i].elf_val];
  3012. }
  3013. for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
  3014. i++)
  3015. {
  3016. if (mips16_reloc_map[i].bfd_val == code)
  3017. return &howto16_table[(int) mips16_reloc_map[i].elf_val];
  3018. }
  3019. for (i = 0; i < sizeof (micromips_reloc_map) / sizeof (struct elf_reloc_map);
  3020. i++)
  3021. {
  3022. if (micromips_reloc_map[i].bfd_val == code)
  3023. return &howto_micromips_table[(int) micromips_reloc_map[i].elf_val];
  3024. }
  3025. switch (code)
  3026. {
  3027. case BFD_RELOC_VTABLE_INHERIT:
  3028. return &elf_mips_gnu_vtinherit_howto;
  3029. case BFD_RELOC_VTABLE_ENTRY:
  3030. return &elf_mips_gnu_vtentry_howto;
  3031. case BFD_RELOC_32_PCREL:
  3032. return &elf_mips_gnu_pcrel32;
  3033. case BFD_RELOC_MIPS_EH:
  3034. return &elf_mips_eh_howto;
  3035. case BFD_RELOC_MIPS_COPY:
  3036. return &elf_mips_copy_howto;
  3037. case BFD_RELOC_MIPS_JUMP_SLOT:
  3038. return &elf_mips_jump_slot_howto;
  3039. default:
  3040. bfd_set_error (bfd_error_bad_value);
  3041. return NULL;
  3042. }
  3043. }
  3044. static reloc_howto_type *
  3045. bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
  3046. const char *r_name)
  3047. {
  3048. unsigned int i;
  3049. for (i = 0;
  3050. i < (sizeof (elf_mips_howto_table_rela)
  3051. / sizeof (elf_mips_howto_table_rela[0]));
  3052. i++)
  3053. if (elf_mips_howto_table_rela[i].name != NULL
  3054. && strcasecmp (elf_mips_howto_table_rela[i].name, r_name) == 0)
  3055. return &elf_mips_howto_table_rela[i];
  3056. for (i = 0;
  3057. i < (sizeof (elf_mips16_howto_table_rela)
  3058. / sizeof (elf_mips16_howto_table_rela[0]));
  3059. i++)
  3060. if (elf_mips16_howto_table_rela[i].name != NULL
  3061. && strcasecmp (elf_mips16_howto_table_rela[i].name, r_name) == 0)
  3062. return &elf_mips16_howto_table_rela[i];
  3063. for (i = 0;
  3064. i < (sizeof (elf_micromips_howto_table_rela)
  3065. / sizeof (elf_micromips_howto_table_rela[0]));
  3066. i++)
  3067. if (elf_micromips_howto_table_rela[i].name != NULL
  3068. && strcasecmp (elf_micromips_howto_table_rela[i].name, r_name) == 0)
  3069. return &elf_micromips_howto_table_rela[i];
  3070. if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0)
  3071. return &elf_mips_gnu_vtinherit_howto;
  3072. if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0)
  3073. return &elf_mips_gnu_vtentry_howto;
  3074. if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0)
  3075. return &elf_mips_gnu_rel16_s2;
  3076. if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0)
  3077. return &elf_mips_gnu_rela16_s2;
  3078. if (strcasecmp (elf_mips_gnu_pcrel32.name, r_name) == 0)
  3079. return &elf_mips_gnu_pcrel32;
  3080. if (strcasecmp (elf_mips_eh_howto.name, r_name) == 0)
  3081. return &elf_mips_eh_howto;
  3082. if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
  3083. return &elf_mips_copy_howto;
  3084. if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
  3085. return &elf_mips_jump_slot_howto;
  3086. return NULL;
  3087. }
  3088. /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
  3089. static reloc_howto_type *
  3090. mips_elf_n32_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
  3091. {
  3092. switch (r_type)
  3093. {
  3094. case R_MIPS_GNU_VTINHERIT:
  3095. return &elf_mips_gnu_vtinherit_howto;
  3096. case R_MIPS_GNU_VTENTRY:
  3097. return &elf_mips_gnu_vtentry_howto;
  3098. case R_MIPS_GNU_REL16_S2:
  3099. if (rela_p)
  3100. return &elf_mips_gnu_rela16_s2;
  3101. else
  3102. return &elf_mips_gnu_rel16_s2;
  3103. case R_MIPS_PC32:
  3104. return &elf_mips_gnu_pcrel32;
  3105. case R_MIPS_EH:
  3106. return &elf_mips_eh_howto;
  3107. case R_MIPS_COPY:
  3108. return &elf_mips_copy_howto;
  3109. case R_MIPS_JUMP_SLOT:
  3110. return &elf_mips_jump_slot_howto;
  3111. default:
  3112. if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max)
  3113. {
  3114. if (rela_p)
  3115. return &elf_micromips_howto_table_rela[r_type - R_MICROMIPS_min];
  3116. else
  3117. return &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min];
  3118. }
  3119. if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
  3120. {
  3121. if (rela_p)
  3122. return &elf_mips16_howto_table_rela[r_type - R_MIPS16_min];
  3123. else
  3124. return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
  3125. }
  3126. if (r_type >= R_MIPS_max)
  3127. {
  3128. (*_bfd_error_handler) (_("unrecognised MIPS reloc number: %d"), r_type);
  3129. bfd_set_error (bfd_error_bad_value);
  3130. r_type = R_MIPS_NONE;
  3131. }
  3132. if (rela_p)
  3133. return &elf_mips_howto_table_rela[r_type];
  3134. else
  3135. return &elf_mips_howto_table_rel[r_type];
  3136. break;
  3137. }
  3138. }
  3139. /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */
  3140. static void
  3141. mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
  3142. {
  3143. unsigned int r_type;
  3144. r_type = ELF32_R_TYPE (dst->r_info);
  3145. cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, FALSE);
  3146. /* The addend for a GPREL16 or LITERAL relocation comes from the GP
  3147. value for the object file. We get the addend now, rather than
  3148. when we do the relocation, because the symbol manipulations done
  3149. by the linker may cause us to lose track of the input BFD. */
  3150. if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
  3151. && (gprel16_reloc_p (r_type) || r_type == (unsigned int) R_MIPS_LITERAL))
  3152. cache_ptr->addend = elf_gp (abfd);
  3153. }
  3154. /* Given a MIPS Elf_Internal_Rela, fill in an arelent structure. */
  3155. static void
  3156. mips_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
  3157. arelent *cache_ptr, Elf_Internal_Rela *dst)
  3158. {
  3159. unsigned int r_type;
  3160. r_type = ELF32_R_TYPE (dst->r_info);
  3161. cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, TRUE);
  3162. cache_ptr->addend = dst->r_addend;
  3163. }
  3164. /* Determine whether a symbol is global for the purposes of splitting
  3165. the symbol table into global symbols and local symbols. At least
  3166. on Irix 5, this split must be between section symbols and all other
  3167. symbols. On most ELF targets the split is between static symbols
  3168. and externally visible symbols. */
  3169. static bfd_boolean
  3170. mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
  3171. {
  3172. if (SGI_COMPAT (abfd))
  3173. return (sym->flags & BSF_SECTION_SYM) == 0;
  3174. else
  3175. return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
  3176. || bfd_is_und_section (bfd_get_section (sym))
  3177. || bfd_is_com_section (bfd_get_section (sym)));
  3178. }
  3179. /* Set the right machine number for a MIPS ELF file. */
  3180. static bfd_boolean
  3181. mips_elf_n32_object_p (bfd *abfd)
  3182. {
  3183. unsigned long mach;
  3184. if (!ABI_N32_P (abfd))
  3185. return FALSE;
  3186. /* Irix 5 and 6 are broken. Object file symbol tables are not always
  3187. sorted correctly such that local symbols precede global symbols,
  3188. and the sh_info field in the symbol table is not always right. */
  3189. if (SGI_COMPAT (abfd))
  3190. elf_bad_symtab (abfd) = TRUE;
  3191. mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
  3192. bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
  3193. return TRUE;
  3194. }
  3195. /* Support for core dump NOTE sections. */
  3196. static bfd_boolean
  3197. elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
  3198. {
  3199. int offset;
  3200. unsigned int size;
  3201. switch (note->descsz)
  3202. {
  3203. default:
  3204. return FALSE;
  3205. case 440: /* Linux/MIPS N32 */
  3206. /* pr_cursig */
  3207. elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
  3208. /* pr_pid */
  3209. elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
  3210. /* pr_reg */
  3211. offset = 72;
  3212. size = 360;
  3213. break;
  3214. }
  3215. /* Make a ".reg/999" section. */
  3216. return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
  3217. note->descpos + offset);
  3218. }
  3219. static bfd_boolean
  3220. elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
  3221. {
  3222. switch (note->descsz)
  3223. {
  3224. default:
  3225. return FALSE;
  3226. case 128: /* Linux/MIPS elf_prpsinfo */
  3227. elf_tdata (abfd)->core->program
  3228. = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
  3229. elf_tdata (abfd)->core->command
  3230. = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
  3231. }
  3232. /* Note that for some reason, a spurious space is tacked
  3233. onto the end of the args in some (at least one anyway)
  3234. implementations, so strip it off if it exists. */
  3235. {
  3236. char *command = elf_tdata (abfd)->core->command;
  3237. int n = strlen (command);
  3238. if (0 < n && command[n - 1] == ' ')
  3239. command[n - 1] = '\0';
  3240. }
  3241. return TRUE;
  3242. }
  3243. /* Depending on the target vector we generate some version of Irix
  3244. executables or "normal" MIPS ELF ABI executables. */
  3245. static irix_compat_t
  3246. elf_n32_mips_irix_compat (bfd *abfd)
  3247. {
  3248. if ((abfd->xvec == &mips_elf32_n_be_vec)
  3249. || (abfd->xvec == &mips_elf32_n_le_vec))
  3250. return ict_irix6;
  3251. else
  3252. return ict_none;
  3253. }
  3254. /* ECOFF swapping routines. These are used when dealing with the
  3255. .mdebug section, which is in the ECOFF debugging format. */
  3256. static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
  3257. /* Symbol table magic number. */
  3258. magicSym,
  3259. /* Alignment of debugging information. E.g., 4. */
  3260. 4,
  3261. /* Sizes of external symbolic information. */
  3262. sizeof (struct hdr_ext),
  3263. sizeof (struct dnr_ext),
  3264. sizeof (struct pdr_ext),
  3265. sizeof (struct sym_ext),
  3266. sizeof (struct opt_ext),
  3267. sizeof (struct fdr_ext),
  3268. sizeof (struct rfd_ext),
  3269. sizeof (struct ext_ext),
  3270. /* Functions to swap in external symbolic data. */
  3271. ecoff_swap_hdr_in,
  3272. ecoff_swap_dnr_in,
  3273. ecoff_swap_pdr_in,
  3274. ecoff_swap_sym_in,
  3275. ecoff_swap_opt_in,
  3276. ecoff_swap_fdr_in,
  3277. ecoff_swap_rfd_in,
  3278. ecoff_swap_ext_in,
  3279. _bfd_ecoff_swap_tir_in,
  3280. _bfd_ecoff_swap_rndx_in,
  3281. /* Functions to swap out external symbolic data. */
  3282. ecoff_swap_hdr_out,
  3283. ecoff_swap_dnr_out,
  3284. ecoff_swap_pdr_out,
  3285. ecoff_swap_sym_out,
  3286. ecoff_swap_opt_out,
  3287. ecoff_swap_fdr_out,
  3288. ecoff_swap_rfd_out,
  3289. ecoff_swap_ext_out,
  3290. _bfd_ecoff_swap_tir_out,
  3291. _bfd_ecoff_swap_rndx_out,
  3292. /* Function to read in symbolic data. */
  3293. _bfd_mips_elf_read_ecoff_info
  3294. };
  3295. #define ELF_ARCH bfd_arch_mips
  3296. #define ELF_TARGET_ID MIPS_ELF_DATA
  3297. #define ELF_MACHINE_CODE EM_MIPS
  3298. #define elf_backend_collect TRUE
  3299. #define elf_backend_type_change_ok TRUE
  3300. #define elf_backend_can_gc_sections TRUE
  3301. #define elf_backend_gc_mark_extra_sections \
  3302. _bfd_mips_elf_gc_mark_extra_sections
  3303. #define elf_info_to_howto mips_info_to_howto_rela
  3304. #define elf_info_to_howto_rel mips_info_to_howto_rel
  3305. #define elf_backend_sym_is_global mips_elf_sym_is_global
  3306. #define elf_backend_object_p mips_elf_n32_object_p
  3307. #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
  3308. #define elf_backend_section_processing _bfd_mips_elf_section_processing
  3309. #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
  3310. #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
  3311. #define elf_backend_section_from_bfd_section \
  3312. _bfd_mips_elf_section_from_bfd_section
  3313. #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
  3314. #define elf_backend_link_output_symbol_hook \
  3315. _bfd_mips_elf_link_output_symbol_hook
  3316. #define elf_backend_create_dynamic_sections \
  3317. _bfd_mips_elf_create_dynamic_sections
  3318. #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
  3319. #define elf_backend_merge_symbol_attribute \
  3320. _bfd_mips_elf_merge_symbol_attribute
  3321. #define elf_backend_get_target_dtag _bfd_mips_elf_get_target_dtag
  3322. #define elf_backend_adjust_dynamic_symbol \
  3323. _bfd_mips_elf_adjust_dynamic_symbol
  3324. #define elf_backend_always_size_sections \
  3325. _bfd_mips_elf_always_size_sections
  3326. #define elf_backend_size_dynamic_sections \
  3327. _bfd_mips_elf_size_dynamic_sections
  3328. #define elf_backend_init_index_section _bfd_elf_init_1_index_section
  3329. #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
  3330. #define elf_backend_finish_dynamic_symbol \
  3331. _bfd_mips_elf_finish_dynamic_symbol
  3332. #define elf_backend_finish_dynamic_sections \
  3333. _bfd_mips_elf_finish_dynamic_sections
  3334. #define elf_backend_final_write_processing \
  3335. _bfd_mips_elf_final_write_processing
  3336. #define elf_backend_additional_program_headers \
  3337. _bfd_mips_elf_additional_program_headers
  3338. #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
  3339. #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
  3340. #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
  3341. #define elf_backend_copy_indirect_symbol \
  3342. _bfd_mips_elf_copy_indirect_symbol
  3343. #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
  3344. #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
  3345. #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
  3346. #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
  3347. /* MIPS n32 ELF can use a mixture of REL and RELA, but some Relocations
  3348. work better/work only in RELA, so we default to this. */
  3349. #define elf_backend_may_use_rel_p 1
  3350. #define elf_backend_may_use_rela_p 1
  3351. #define elf_backend_default_use_rela_p 1
  3352. #define elf_backend_rela_plts_and_copies_p 0
  3353. #define elf_backend_sign_extend_vma TRUE
  3354. #define elf_backend_plt_readonly 1
  3355. #define elf_backend_plt_sym_val _bfd_mips_elf_plt_sym_val
  3356. #define elf_backend_discard_info _bfd_mips_elf_discard_info
  3357. #define elf_backend_ignore_discarded_relocs \
  3358. _bfd_mips_elf_ignore_discarded_relocs
  3359. #define elf_backend_write_section _bfd_mips_elf_write_section
  3360. #define elf_backend_mips_irix_compat elf_n32_mips_irix_compat
  3361. #define elf_backend_mips_rtype_to_howto mips_elf_n32_rtype_to_howto
  3362. #define bfd_elf32_bfd_is_target_special_symbol \
  3363. _bfd_mips_elf_is_target_special_symbol
  3364. #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
  3365. #define bfd_elf32_find_inliner_info _bfd_mips_elf_find_inliner_info
  3366. #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
  3367. #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
  3368. #define bfd_elf32_bfd_get_relocated_section_contents \
  3369. _bfd_elf_mips_get_relocated_section_contents
  3370. #define bfd_elf32_bfd_link_hash_table_create \
  3371. _bfd_mips_elf_link_hash_table_create
  3372. #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
  3373. #define bfd_elf32_bfd_merge_private_bfd_data \
  3374. _bfd_mips_elf_merge_private_bfd_data
  3375. #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
  3376. #define bfd_elf32_bfd_print_private_bfd_data \
  3377. _bfd_mips_elf_print_private_bfd_data
  3378. #define bfd_elf32_bfd_relax_section _bfd_mips_relax_section
  3379. #define bfd_elf32_mkobject _bfd_mips_elf_mkobject
  3380. /* Support for SGI-ish mips targets using n32 ABI. */
  3381. #define TARGET_LITTLE_SYM mips_elf32_n_le_vec
  3382. #define TARGET_LITTLE_NAME "elf32-nlittlemips"
  3383. #define TARGET_BIG_SYM mips_elf32_n_be_vec
  3384. #define TARGET_BIG_NAME "elf32-nbigmips"
  3385. #define ELF_MAXPAGESIZE 0x10000
  3386. #define ELF_COMMONPAGESIZE 0x1000
  3387. #include "elf32-target.h"
  3388. /* Support for traditional mips targets using n32 ABI. */
  3389. #undef TARGET_LITTLE_SYM
  3390. #undef TARGET_LITTLE_NAME
  3391. #undef TARGET_BIG_SYM
  3392. #undef TARGET_BIG_NAME
  3393. #undef ELF_MAXPAGESIZE
  3394. #undef ELF_COMMONPAGESIZE
  3395. #define TARGET_LITTLE_SYM mips_elf32_ntrad_le_vec
  3396. #define TARGET_LITTLE_NAME "elf32-ntradlittlemips"
  3397. #define TARGET_BIG_SYM mips_elf32_ntrad_be_vec
  3398. #define TARGET_BIG_NAME "elf32-ntradbigmips"
  3399. #define ELF_MAXPAGESIZE 0x10000
  3400. #define ELF_COMMONPAGESIZE 0x1000
  3401. #define elf32_bed elf32_tradbed
  3402. /* Include the target file again for this target. */
  3403. #include "elf32-target.h"
  3404. /* FreeBSD support. */
  3405. #undef TARGET_LITTLE_SYM
  3406. #undef TARGET_LITTLE_NAME
  3407. #undef TARGET_BIG_SYM
  3408. #undef TARGET_BIG_NAME
  3409. #define TARGET_LITTLE_SYM mips_elf32_ntradfbsd_le_vec
  3410. #define TARGET_LITTLE_NAME "elf32-ntradlittlemips-freebsd"
  3411. #define TARGET_BIG_SYM mips_elf32_ntradfbsd_be_vec
  3412. #define TARGET_BIG_NAME "elf32-ntradbigmips-freebsd"
  3413. #undef ELF_OSABI
  3414. #define ELF_OSABI ELFOSABI_FREEBSD
  3415. #undef elf32_bed
  3416. #define elf32_bed elf32_fbsd_tradbed
  3417. #include "elf32-target.h"