elf64-mips.c 142 KB

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