elfn32-mips.c 135 KB

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