elf32-tic6x.c 124 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449
  1. /* 32-bit ELF support for TI C6X
  2. Copyright (C) 2010-2015 Free Software Foundation, Inc.
  3. Contributed by Joseph Myers <joseph@codesourcery.com>
  4. Bernd Schmidt <bernds@codesourcery.com>
  5. This file is part of BFD, the Binary File Descriptor library.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  17. MA 02110-1301, USA. */
  18. #include "sysdep.h"
  19. #include <limits.h>
  20. #include "bfd.h"
  21. #include "libbfd.h"
  22. #include "libiberty.h"
  23. #include "elf-bfd.h"
  24. #include "elf/tic6x.h"
  25. #include "elf32-tic6x.h"
  26. #define ELF_DYNAMIC_INTERPRETER "/lib/ld-uClibc.so.0"
  27. /* DSBT binaries have a default 128K stack. */
  28. #define DEFAULT_STACK_SIZE 0x20000
  29. /* The size in bytes of an entry in the procedure linkage table. */
  30. #define PLT_ENTRY_SIZE 24
  31. /* TI C6X ELF linker hash table. */
  32. struct elf32_tic6x_link_hash_table
  33. {
  34. struct elf_link_hash_table elf;
  35. /* Short-cuts to get to dynamic linker sections. */
  36. asection *sdynbss;
  37. asection *srelbss;
  38. /* C6X specific command line arguments. */
  39. struct elf32_tic6x_params params;
  40. /* Small local sym cache. */
  41. struct sym_cache sym_cache;
  42. /* The output BFD, for convenience. */
  43. bfd *obfd;
  44. /* The .dsbt section. */
  45. asection *dsbt;
  46. };
  47. /* Get the TI C6X ELF linker hash table from a link_info structure. */
  48. #define elf32_tic6x_hash_table(p) \
  49. ((struct elf32_tic6x_link_hash_table *) ((p)->hash))
  50. /* TI C6X ELF linker hash entry. */
  51. struct elf32_tic6x_link_hash_entry
  52. {
  53. struct elf_link_hash_entry elf;
  54. /* Track dynamic relocs copied for this symbol. */
  55. struct elf_dyn_relocs *dyn_relocs;
  56. };
  57. typedef enum
  58. {
  59. DELETE_EXIDX_ENTRY,
  60. INSERT_EXIDX_CANTUNWIND_AT_END
  61. }
  62. tic6x_unwind_edit_type;
  63. /* A (sorted) list of edits to apply to an unwind table. */
  64. typedef struct tic6x_unwind_table_edit
  65. {
  66. tic6x_unwind_edit_type type;
  67. /* Note: we sometimes want to insert an unwind entry corresponding to a
  68. section different from the one we're currently writing out, so record the
  69. (text) section this edit relates to here. */
  70. asection *linked_section;
  71. unsigned int index;
  72. struct tic6x_unwind_table_edit *next;
  73. }
  74. tic6x_unwind_table_edit;
  75. typedef struct _tic6x_elf_section_data
  76. {
  77. /* Information about mapping symbols. */
  78. struct bfd_elf_section_data elf;
  79. /* Information about unwind tables. */
  80. union
  81. {
  82. /* Unwind info attached to a text section. */
  83. struct
  84. {
  85. asection *tic6x_exidx_sec;
  86. } text;
  87. /* Unwind info attached to an .c6xabi.exidx section. */
  88. struct
  89. {
  90. tic6x_unwind_table_edit *unwind_edit_list;
  91. tic6x_unwind_table_edit *unwind_edit_tail;
  92. } exidx;
  93. } u;
  94. }
  95. _tic6x_elf_section_data;
  96. #define elf32_tic6x_section_data(sec) \
  97. ((_tic6x_elf_section_data *) elf_section_data (sec))
  98. struct elf32_tic6x_obj_tdata
  99. {
  100. struct elf_obj_tdata root;
  101. /* Whether to use RELA relocations when generating relocations.
  102. This is a per-object flag to allow the assembler to generate REL
  103. relocations for use in linker testcases. */
  104. bfd_boolean use_rela_p;
  105. };
  106. #define elf32_tic6x_tdata(abfd) \
  107. ((struct elf32_tic6x_obj_tdata *) (abfd)->tdata.any)
  108. #define is_tic6x_elf(bfd) \
  109. (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
  110. && elf_tdata (bfd) != NULL \
  111. && elf_object_id (bfd) == TIC6X_ELF_DATA)
  112. /* C6X ELF uses two common sections. One is the usual one, and the
  113. other is for small objects. All the small objects are kept
  114. together, and then referenced via the gp pointer, which yields
  115. faster assembler code. This is what we use for the small common
  116. section. This approach is copied from ecoff.c. */
  117. static asection tic6x_elf_scom_section;
  118. static asymbol tic6x_elf_scom_symbol;
  119. static asymbol *tic6x_elf_scom_symbol_ptr;
  120. static reloc_howto_type elf32_tic6x_howto_table[] =
  121. {
  122. HOWTO (R_C6000_NONE, /* type */
  123. 0, /* rightshift */
  124. 3, /* size (0 = byte, 1 = short, 2 = long) */
  125. 0, /* bitsize */
  126. FALSE, /* pc_relative */
  127. 0, /* bitpos */
  128. complain_overflow_dont,/* complain_on_overflow */
  129. bfd_elf_generic_reloc, /* special_function */
  130. "R_C6000_NONE", /* name */
  131. FALSE, /* partial_inplace */
  132. 0, /* src_mask */
  133. 0, /* dst_mask */
  134. FALSE), /* pcrel_offset */
  135. HOWTO (R_C6000_ABS32, /* type */
  136. 0, /* rightshift */
  137. 2, /* size (0 = byte, 1 = short, 2 = long) */
  138. 32, /* bitsize */
  139. FALSE, /* pc_relative */
  140. 0, /* bitpos */
  141. complain_overflow_dont,/* complain_on_overflow */
  142. bfd_elf_generic_reloc, /* special_function */
  143. "R_C6000_ABS32", /* name */
  144. FALSE, /* partial_inplace */
  145. 0, /* src_mask */
  146. 0xffffffff, /* dst_mask */
  147. FALSE), /* pcrel_offset */
  148. HOWTO (R_C6000_ABS16, /* type */
  149. 0, /* rightshift */
  150. 1, /* size (0 = byte, 1 = short, 2 = long) */
  151. 16, /* bitsize */
  152. FALSE, /* pc_relative */
  153. 0, /* bitpos */
  154. complain_overflow_bitfield,/* complain_on_overflow */
  155. bfd_elf_generic_reloc, /* special_function */
  156. "R_C6000_ABS16", /* name */
  157. FALSE, /* partial_inplace */
  158. 0, /* src_mask */
  159. 0x0000ffff, /* dst_mask */
  160. FALSE), /* pcrel_offset */
  161. HOWTO (R_C6000_ABS8, /* type */
  162. 0, /* rightshift */
  163. 0, /* size (0 = byte, 1 = short, 2 = long) */
  164. 8, /* bitsize */
  165. FALSE, /* pc_relative */
  166. 0, /* bitpos */
  167. complain_overflow_bitfield,/* complain_on_overflow */
  168. bfd_elf_generic_reloc, /* special_function */
  169. "R_C6000_ABS8", /* name */
  170. FALSE, /* partial_inplace */
  171. 0, /* src_mask */
  172. 0x000000ff, /* dst_mask */
  173. FALSE), /* pcrel_offset */
  174. HOWTO (R_C6000_PCR_S21, /* type */
  175. 2, /* rightshift */
  176. 2, /* size (0 = byte, 1 = short, 2 = long) */
  177. 21, /* bitsize */
  178. TRUE, /* pc_relative */
  179. 7, /* bitpos */
  180. complain_overflow_signed,/* complain_on_overflow */
  181. bfd_elf_generic_reloc, /* special_function */
  182. "R_C6000_PCR_S21", /* name */
  183. FALSE, /* partial_inplace */
  184. 0, /* src_mask */
  185. 0x0fffff80, /* dst_mask */
  186. TRUE), /* pcrel_offset */
  187. HOWTO (R_C6000_PCR_S12, /* type */
  188. 2, /* rightshift */
  189. 2, /* size (0 = byte, 1 = short, 2 = long) */
  190. 12, /* bitsize */
  191. TRUE, /* pc_relative */
  192. 16, /* bitpos */
  193. complain_overflow_signed,/* complain_on_overflow */
  194. bfd_elf_generic_reloc, /* special_function */
  195. "R_C6000_PCR_S12", /* name */
  196. FALSE, /* partial_inplace */
  197. 0, /* src_mask */
  198. 0x0fff0000, /* dst_mask */
  199. TRUE), /* pcrel_offset */
  200. HOWTO (R_C6000_PCR_S10, /* type */
  201. 2, /* rightshift */
  202. 2, /* size (0 = byte, 1 = short, 2 = long) */
  203. 10, /* bitsize */
  204. TRUE, /* pc_relative */
  205. 13, /* bitpos */
  206. complain_overflow_signed,/* complain_on_overflow */
  207. bfd_elf_generic_reloc, /* special_function */
  208. "R_C6000_PCR_S10", /* name */
  209. FALSE, /* partial_inplace */
  210. 0, /* src_mask */
  211. 0x007fe000, /* dst_mask */
  212. TRUE), /* pcrel_offset */
  213. HOWTO (R_C6000_PCR_S7, /* type */
  214. 2, /* rightshift */
  215. 2, /* size (0 = byte, 1 = short, 2 = long) */
  216. 7, /* bitsize */
  217. TRUE, /* pc_relative */
  218. 16, /* bitpos */
  219. complain_overflow_signed,/* complain_on_overflow */
  220. bfd_elf_generic_reloc, /* special_function */
  221. "R_C6000_PCR_S7", /* name */
  222. FALSE, /* partial_inplace */
  223. 0, /* src_mask */
  224. 0x007f0000, /* dst_mask */
  225. TRUE), /* pcrel_offset */
  226. HOWTO (R_C6000_ABS_S16, /* type */
  227. 0, /* rightshift */
  228. 2, /* size (0 = byte, 1 = short, 2 = long) */
  229. 16, /* bitsize */
  230. FALSE, /* pc_relative */
  231. 7, /* bitpos */
  232. complain_overflow_signed,/* complain_on_overflow */
  233. bfd_elf_generic_reloc, /* special_function */
  234. "R_C6000_ABS_S16", /* name */
  235. FALSE, /* partial_inplace */
  236. 0, /* src_mask */
  237. 0x007fff80, /* dst_mask */
  238. FALSE), /* pcrel_offset */
  239. HOWTO (R_C6000_ABS_L16, /* type */
  240. 0, /* rightshift */
  241. 2, /* size (0 = byte, 1 = short, 2 = long) */
  242. 16, /* bitsize */
  243. FALSE, /* pc_relative */
  244. 7, /* bitpos */
  245. complain_overflow_dont,/* complain_on_overflow */
  246. bfd_elf_generic_reloc, /* special_function */
  247. "R_C6000_ABS_L16", /* name */
  248. FALSE, /* partial_inplace */
  249. 0, /* src_mask */
  250. 0x007fff80, /* dst_mask */
  251. FALSE), /* pcrel_offset */
  252. HOWTO (R_C6000_ABS_H16, /* type */
  253. 16, /* rightshift */
  254. 2, /* size (0 = byte, 1 = short, 2 = long) */
  255. 16, /* bitsize */
  256. FALSE, /* pc_relative */
  257. 7, /* bitpos */
  258. complain_overflow_dont,/* complain_on_overflow */
  259. bfd_elf_generic_reloc, /* special_function */
  260. "R_C6000_ABS_H16", /* name */
  261. FALSE, /* partial_inplace */
  262. 0, /* src_mask */
  263. 0x007fff80, /* dst_mask */
  264. FALSE), /* pcrel_offset */
  265. HOWTO (R_C6000_SBR_U15_B, /* type */
  266. 0, /* rightshift */
  267. 2, /* size (0 = byte, 1 = short, 2 = long) */
  268. 15, /* bitsize */
  269. FALSE, /* pc_relative */
  270. 8, /* bitpos */
  271. complain_overflow_unsigned,/* complain_on_overflow */
  272. bfd_elf_generic_reloc, /* special_function */
  273. "R_C6000_SBR_U15_B", /* name */
  274. FALSE, /* partial_inplace */
  275. 0, /* src_mask */
  276. 0x007fff00, /* dst_mask */
  277. FALSE), /* pcrel_offset */
  278. HOWTO (R_C6000_SBR_U15_H, /* type */
  279. 1, /* rightshift */
  280. 2, /* size (0 = byte, 1 = short, 2 = long) */
  281. 15, /* bitsize */
  282. FALSE, /* pc_relative */
  283. 8, /* bitpos */
  284. complain_overflow_unsigned,/* complain_on_overflow */
  285. bfd_elf_generic_reloc, /* special_function */
  286. "R_C6000_SBR_U15_H", /* name */
  287. FALSE, /* partial_inplace */
  288. 0, /* src_mask */
  289. 0x007fff00, /* dst_mask */
  290. FALSE), /* pcrel_offset */
  291. HOWTO (R_C6000_SBR_U15_W, /* type */
  292. 2, /* rightshift */
  293. 2, /* size (0 = byte, 1 = short, 2 = long) */
  294. 15, /* bitsize */
  295. FALSE, /* pc_relative */
  296. 8, /* bitpos */
  297. complain_overflow_unsigned,/* complain_on_overflow */
  298. bfd_elf_generic_reloc, /* special_function */
  299. "R_C6000_SBR_U15_W", /* name */
  300. FALSE, /* partial_inplace */
  301. 0, /* src_mask */
  302. 0x007fff00, /* dst_mask */
  303. FALSE), /* pcrel_offset */
  304. HOWTO (R_C6000_SBR_S16, /* type */
  305. 0, /* rightshift */
  306. 2, /* size (0 = byte, 1 = short, 2 = long) */
  307. 16, /* bitsize */
  308. FALSE, /* pc_relative */
  309. 7, /* bitpos */
  310. complain_overflow_signed,/* complain_on_overflow */
  311. bfd_elf_generic_reloc, /* special_function */
  312. "R_C6000_SBR_S16", /* name */
  313. FALSE, /* partial_inplace */
  314. 0, /* src_mask */
  315. 0x007fff80, /* dst_mask */
  316. FALSE), /* pcrel_offset */
  317. HOWTO (R_C6000_SBR_L16_B, /* type */
  318. 0, /* rightshift */
  319. 2, /* size (0 = byte, 1 = short, 2 = long) */
  320. 16, /* bitsize */
  321. FALSE, /* pc_relative */
  322. 7, /* bitpos */
  323. complain_overflow_dont,/* complain_on_overflow */
  324. bfd_elf_generic_reloc, /* special_function */
  325. "R_C6000_SBR_L16_B", /* name */
  326. FALSE, /* partial_inplace */
  327. 0, /* src_mask */
  328. 0x007fff80, /* dst_mask */
  329. FALSE), /* pcrel_offset */
  330. HOWTO (R_C6000_SBR_L16_H, /* type */
  331. 1, /* rightshift */
  332. 2, /* size (0 = byte, 1 = short, 2 = long) */
  333. 16, /* bitsize */
  334. FALSE, /* pc_relative */
  335. 7, /* bitpos */
  336. complain_overflow_dont,/* complain_on_overflow */
  337. bfd_elf_generic_reloc, /* special_function */
  338. "R_C6000_SBR_L16_H", /* name */
  339. FALSE, /* partial_inplace */
  340. 0, /* src_mask */
  341. 0x007fff80, /* dst_mask */
  342. FALSE), /* pcrel_offset */
  343. HOWTO (R_C6000_SBR_L16_W, /* type */
  344. 2, /* rightshift */
  345. 2, /* size (0 = byte, 1 = short, 2 = long) */
  346. 16, /* bitsize */
  347. FALSE, /* pc_relative */
  348. 7, /* bitpos */
  349. complain_overflow_dont,/* complain_on_overflow */
  350. bfd_elf_generic_reloc, /* special_function */
  351. "R_C6000_SBR_L16_W", /* name */
  352. FALSE, /* partial_inplace */
  353. 0, /* src_mask */
  354. 0x007fff80, /* dst_mask */
  355. FALSE), /* pcrel_offset */
  356. HOWTO (R_C6000_SBR_H16_B, /* type */
  357. 16, /* rightshift */
  358. 2, /* size (0 = byte, 1 = short, 2 = long) */
  359. 16, /* bitsize */
  360. FALSE, /* pc_relative */
  361. 7, /* bitpos */
  362. complain_overflow_dont,/* complain_on_overflow */
  363. bfd_elf_generic_reloc, /* special_function */
  364. "R_C6000_SBR_H16_B", /* name */
  365. FALSE, /* partial_inplace */
  366. 0, /* src_mask */
  367. 0x007fff80, /* dst_mask */
  368. FALSE), /* pcrel_offset */
  369. HOWTO (R_C6000_SBR_H16_H, /* type */
  370. 17, /* rightshift */
  371. 2, /* size (0 = byte, 1 = short, 2 = long) */
  372. 16, /* bitsize */
  373. FALSE, /* pc_relative */
  374. 7, /* bitpos */
  375. complain_overflow_dont,/* complain_on_overflow */
  376. bfd_elf_generic_reloc, /* special_function */
  377. "R_C6000_SBR_H16_H", /* name */
  378. FALSE, /* partial_inplace */
  379. 0, /* src_mask */
  380. 0x007fff80, /* dst_mask */
  381. FALSE), /* pcrel_offset */
  382. HOWTO (R_C6000_SBR_H16_W, /* type */
  383. 18, /* rightshift */
  384. 2, /* size (0 = byte, 1 = short, 2 = long) */
  385. 16, /* bitsize */
  386. FALSE, /* pc_relative */
  387. 7, /* bitpos */
  388. complain_overflow_dont,/* complain_on_overflow */
  389. bfd_elf_generic_reloc, /* special_function */
  390. "R_C6000_SBR_H16_W", /* name */
  391. FALSE, /* partial_inplace */
  392. 0, /* src_mask */
  393. 0x007fff80, /* dst_mask */
  394. FALSE), /* pcrel_offset */
  395. HOWTO (R_C6000_SBR_GOT_U15_W, /* type */
  396. 2, /* rightshift */
  397. 2, /* size (0 = byte, 1 = short, 2 = long) */
  398. 15, /* bitsize */
  399. FALSE, /* pc_relative */
  400. 8, /* bitpos */
  401. complain_overflow_unsigned,/* complain_on_overflow */
  402. bfd_elf_generic_reloc, /* special_function */
  403. "R_C6000_SBR_GOT_U15_W",/* name */
  404. FALSE, /* partial_inplace */
  405. 0, /* src_mask */
  406. 0x007fff00, /* dst_mask */
  407. FALSE), /* pcrel_offset */
  408. HOWTO (R_C6000_SBR_GOT_L16_W, /* type */
  409. 2, /* rightshift */
  410. 2, /* size (0 = byte, 1 = short, 2 = long) */
  411. 16, /* bitsize */
  412. FALSE, /* pc_relative */
  413. 7, /* bitpos */
  414. complain_overflow_dont,/* complain_on_overflow */
  415. bfd_elf_generic_reloc, /* special_function */
  416. "R_C6000_SBR_GOT_L16_W",/* name */
  417. FALSE, /* partial_inplace */
  418. 0, /* src_mask */
  419. 0x007fff80, /* dst_mask */
  420. FALSE), /* pcrel_offset */
  421. HOWTO (R_C6000_SBR_GOT_H16_W, /* type */
  422. 18, /* rightshift */
  423. 2, /* size (0 = byte, 1 = short, 2 = long) */
  424. 16, /* bitsize */
  425. FALSE, /* pc_relative */
  426. 7, /* bitpos */
  427. complain_overflow_dont,/* complain_on_overflow */
  428. bfd_elf_generic_reloc, /* special_function */
  429. "R_C6000_SBR_GOT_H16_W",/* name */
  430. FALSE, /* partial_inplace */
  431. 0, /* src_mask */
  432. 0x007fff80, /* dst_mask */
  433. FALSE), /* pcrel_offset */
  434. HOWTO (R_C6000_DSBT_INDEX, /* type */
  435. 0, /* rightshift */
  436. 2, /* size (0 = byte, 1 = short, 2 = long) */
  437. 15, /* bitsize */
  438. FALSE, /* pc_relative */
  439. 8, /* bitpos */
  440. complain_overflow_unsigned,/* complain_on_overflow */
  441. bfd_elf_generic_reloc, /* special_function */
  442. "R_C6000_DSBT_INDEX", /* name */
  443. FALSE, /* partial_inplace */
  444. 0, /* src_mask */
  445. 0x007fff00, /* dst_mask */
  446. FALSE), /* pcrel_offset */
  447. HOWTO (R_C6000_PREL31, /* type */
  448. 1, /* rightshift */
  449. 2, /* size (0 = byte, 1 = short, 2 = long) */
  450. 31, /* bitsize */
  451. TRUE, /* pc_relative */
  452. 0, /* bitpos */
  453. complain_overflow_dont,/* complain_on_overflow */
  454. bfd_elf_generic_reloc, /* special_function */
  455. "R_C6000_PREL31", /* name */
  456. FALSE, /* partial_inplace */
  457. 0, /* src_mask */
  458. 0x7fffffff, /* dst_mask */
  459. TRUE), /* pcrel_offset */
  460. HOWTO (R_C6000_COPY, /* type */
  461. 0, /* rightshift */
  462. 2, /* size (0 = byte, 1 = short, 2 = long) */
  463. 32, /* bitsize */
  464. FALSE, /* pc_relative */
  465. 0, /* bitpos */
  466. complain_overflow_dont,/* complain_on_overflow */
  467. bfd_elf_generic_reloc, /* special_function */
  468. "R_C6000_COPY", /* name */
  469. FALSE, /* partial_inplace */
  470. 0, /* src_mask */
  471. 0xffffffff, /* dst_mask */
  472. FALSE), /* pcrel_offset */
  473. HOWTO (R_C6000_JUMP_SLOT, /* type */
  474. 0, /* rightshift */
  475. 2, /* size (0 = byte, 1 = short, 2 = long) */
  476. 32, /* bitsize */
  477. FALSE, /* pc_relative */
  478. 0, /* bitpos */
  479. complain_overflow_dont,/* complain_on_overflow */
  480. bfd_elf_generic_reloc, /* special_function */
  481. "R_C6000_JUMP_SLOT", /* name */
  482. FALSE, /* partial_inplace */
  483. 0, /* src_mask */
  484. 0xffffffff, /* dst_mask */
  485. FALSE), /* pcrel_offset */
  486. HOWTO (R_C6000_EHTYPE, /* type */
  487. 0, /* rightshift */
  488. 2, /* size (0 = byte, 1 = short, 2 = long) */
  489. 32, /* bitsize */
  490. FALSE, /* pc_relative */
  491. 0, /* bitpos */
  492. complain_overflow_dont,/* complain_on_overflow */
  493. bfd_elf_generic_reloc, /* special_function */
  494. "R_C6000_EHTYPE", /* name */
  495. FALSE, /* partial_inplace */
  496. 0, /* src_mask */
  497. 0xffffffff, /* dst_mask */
  498. FALSE), /* pcrel_offset */
  499. HOWTO (R_C6000_PCR_H16, /* type */
  500. 16, /* rightshift */
  501. 2, /* size (0 = byte, 1 = short, 2 = long) */
  502. 16, /* bitsize */
  503. TRUE, /* pc_relative */
  504. 7, /* bitpos */
  505. complain_overflow_dont,/* complain_on_overflow */
  506. bfd_elf_generic_reloc, /* special_function */
  507. "R_C6000_PCR_H16", /* name */
  508. FALSE, /* partial_inplace */
  509. 0, /* src_mask */
  510. 0x007fff80, /* dst_mask */
  511. TRUE), /* pcrel_offset */
  512. HOWTO (R_C6000_PCR_L16, /* type */
  513. 0, /* rightshift */
  514. 2, /* size (0 = byte, 1 = short, 2 = long) */
  515. 16, /* bitsize */
  516. TRUE, /* pc_relative */
  517. 7, /* bitpos */
  518. complain_overflow_dont,/* complain_on_overflow */
  519. bfd_elf_generic_reloc, /* special_function */
  520. "R_C6000_PCR_L16", /* name */
  521. FALSE, /* partial_inplace */
  522. 0, /* src_mask */
  523. 0x007fff80, /* dst_mask */
  524. TRUE), /* pcrel_offset */
  525. EMPTY_HOWTO (31),
  526. EMPTY_HOWTO (32),
  527. EMPTY_HOWTO (33),
  528. EMPTY_HOWTO (34),
  529. EMPTY_HOWTO (35),
  530. EMPTY_HOWTO (36),
  531. EMPTY_HOWTO (37),
  532. EMPTY_HOWTO (38),
  533. EMPTY_HOWTO (39),
  534. EMPTY_HOWTO (40),
  535. EMPTY_HOWTO (41),
  536. EMPTY_HOWTO (42),
  537. EMPTY_HOWTO (43),
  538. EMPTY_HOWTO (44),
  539. EMPTY_HOWTO (45),
  540. EMPTY_HOWTO (46),
  541. EMPTY_HOWTO (47),
  542. EMPTY_HOWTO (48),
  543. EMPTY_HOWTO (49),
  544. EMPTY_HOWTO (50),
  545. EMPTY_HOWTO (51),
  546. EMPTY_HOWTO (52),
  547. EMPTY_HOWTO (53),
  548. EMPTY_HOWTO (54),
  549. EMPTY_HOWTO (55),
  550. EMPTY_HOWTO (56),
  551. EMPTY_HOWTO (57),
  552. EMPTY_HOWTO (58),
  553. EMPTY_HOWTO (59),
  554. EMPTY_HOWTO (60),
  555. EMPTY_HOWTO (61),
  556. EMPTY_HOWTO (62),
  557. EMPTY_HOWTO (63),
  558. EMPTY_HOWTO (64),
  559. EMPTY_HOWTO (65),
  560. EMPTY_HOWTO (66),
  561. EMPTY_HOWTO (67),
  562. EMPTY_HOWTO (68),
  563. EMPTY_HOWTO (69),
  564. EMPTY_HOWTO (70),
  565. EMPTY_HOWTO (71),
  566. EMPTY_HOWTO (72),
  567. EMPTY_HOWTO (73),
  568. EMPTY_HOWTO (74),
  569. EMPTY_HOWTO (75),
  570. EMPTY_HOWTO (76),
  571. EMPTY_HOWTO (77),
  572. EMPTY_HOWTO (78),
  573. EMPTY_HOWTO (79),
  574. EMPTY_HOWTO (80),
  575. EMPTY_HOWTO (81),
  576. EMPTY_HOWTO (82),
  577. EMPTY_HOWTO (83),
  578. EMPTY_HOWTO (84),
  579. EMPTY_HOWTO (85),
  580. EMPTY_HOWTO (86),
  581. EMPTY_HOWTO (87),
  582. EMPTY_HOWTO (88),
  583. EMPTY_HOWTO (89),
  584. EMPTY_HOWTO (90),
  585. EMPTY_HOWTO (91),
  586. EMPTY_HOWTO (92),
  587. EMPTY_HOWTO (93),
  588. EMPTY_HOWTO (94),
  589. EMPTY_HOWTO (95),
  590. EMPTY_HOWTO (96),
  591. EMPTY_HOWTO (97),
  592. EMPTY_HOWTO (98),
  593. EMPTY_HOWTO (99),
  594. EMPTY_HOWTO (100),
  595. EMPTY_HOWTO (101),
  596. EMPTY_HOWTO (102),
  597. EMPTY_HOWTO (103),
  598. EMPTY_HOWTO (104),
  599. EMPTY_HOWTO (105),
  600. EMPTY_HOWTO (106),
  601. EMPTY_HOWTO (107),
  602. EMPTY_HOWTO (108),
  603. EMPTY_HOWTO (109),
  604. EMPTY_HOWTO (110),
  605. EMPTY_HOWTO (111),
  606. EMPTY_HOWTO (112),
  607. EMPTY_HOWTO (113),
  608. EMPTY_HOWTO (114),
  609. EMPTY_HOWTO (115),
  610. EMPTY_HOWTO (116),
  611. EMPTY_HOWTO (117),
  612. EMPTY_HOWTO (118),
  613. EMPTY_HOWTO (119),
  614. EMPTY_HOWTO (120),
  615. EMPTY_HOWTO (121),
  616. EMPTY_HOWTO (122),
  617. EMPTY_HOWTO (123),
  618. EMPTY_HOWTO (124),
  619. EMPTY_HOWTO (125),
  620. EMPTY_HOWTO (126),
  621. EMPTY_HOWTO (127),
  622. EMPTY_HOWTO (128),
  623. EMPTY_HOWTO (129),
  624. EMPTY_HOWTO (130),
  625. EMPTY_HOWTO (131),
  626. EMPTY_HOWTO (132),
  627. EMPTY_HOWTO (133),
  628. EMPTY_HOWTO (134),
  629. EMPTY_HOWTO (135),
  630. EMPTY_HOWTO (136),
  631. EMPTY_HOWTO (137),
  632. EMPTY_HOWTO (138),
  633. EMPTY_HOWTO (139),
  634. EMPTY_HOWTO (140),
  635. EMPTY_HOWTO (141),
  636. EMPTY_HOWTO (142),
  637. EMPTY_HOWTO (143),
  638. EMPTY_HOWTO (144),
  639. EMPTY_HOWTO (145),
  640. EMPTY_HOWTO (146),
  641. EMPTY_HOWTO (147),
  642. EMPTY_HOWTO (148),
  643. EMPTY_HOWTO (149),
  644. EMPTY_HOWTO (150),
  645. EMPTY_HOWTO (151),
  646. EMPTY_HOWTO (152),
  647. EMPTY_HOWTO (153),
  648. EMPTY_HOWTO (154),
  649. EMPTY_HOWTO (155),
  650. EMPTY_HOWTO (156),
  651. EMPTY_HOWTO (157),
  652. EMPTY_HOWTO (158),
  653. EMPTY_HOWTO (159),
  654. EMPTY_HOWTO (160),
  655. EMPTY_HOWTO (161),
  656. EMPTY_HOWTO (162),
  657. EMPTY_HOWTO (163),
  658. EMPTY_HOWTO (164),
  659. EMPTY_HOWTO (165),
  660. EMPTY_HOWTO (166),
  661. EMPTY_HOWTO (167),
  662. EMPTY_HOWTO (168),
  663. EMPTY_HOWTO (169),
  664. EMPTY_HOWTO (170),
  665. EMPTY_HOWTO (171),
  666. EMPTY_HOWTO (172),
  667. EMPTY_HOWTO (173),
  668. EMPTY_HOWTO (174),
  669. EMPTY_HOWTO (175),
  670. EMPTY_HOWTO (176),
  671. EMPTY_HOWTO (177),
  672. EMPTY_HOWTO (178),
  673. EMPTY_HOWTO (179),
  674. EMPTY_HOWTO (180),
  675. EMPTY_HOWTO (181),
  676. EMPTY_HOWTO (182),
  677. EMPTY_HOWTO (183),
  678. EMPTY_HOWTO (184),
  679. EMPTY_HOWTO (185),
  680. EMPTY_HOWTO (186),
  681. EMPTY_HOWTO (187),
  682. EMPTY_HOWTO (188),
  683. EMPTY_HOWTO (189),
  684. EMPTY_HOWTO (190),
  685. EMPTY_HOWTO (191),
  686. EMPTY_HOWTO (192),
  687. EMPTY_HOWTO (193),
  688. EMPTY_HOWTO (194),
  689. EMPTY_HOWTO (195),
  690. EMPTY_HOWTO (196),
  691. EMPTY_HOWTO (197),
  692. EMPTY_HOWTO (198),
  693. EMPTY_HOWTO (199),
  694. EMPTY_HOWTO (200),
  695. EMPTY_HOWTO (201),
  696. EMPTY_HOWTO (202),
  697. EMPTY_HOWTO (203),
  698. EMPTY_HOWTO (204),
  699. EMPTY_HOWTO (205),
  700. EMPTY_HOWTO (206),
  701. EMPTY_HOWTO (207),
  702. EMPTY_HOWTO (208),
  703. EMPTY_HOWTO (209),
  704. EMPTY_HOWTO (210),
  705. EMPTY_HOWTO (211),
  706. EMPTY_HOWTO (212),
  707. EMPTY_HOWTO (213),
  708. EMPTY_HOWTO (214),
  709. EMPTY_HOWTO (215),
  710. EMPTY_HOWTO (216),
  711. EMPTY_HOWTO (217),
  712. EMPTY_HOWTO (218),
  713. EMPTY_HOWTO (219),
  714. EMPTY_HOWTO (220),
  715. EMPTY_HOWTO (221),
  716. EMPTY_HOWTO (222),
  717. EMPTY_HOWTO (223),
  718. EMPTY_HOWTO (224),
  719. EMPTY_HOWTO (225),
  720. EMPTY_HOWTO (226),
  721. EMPTY_HOWTO (227),
  722. EMPTY_HOWTO (228),
  723. EMPTY_HOWTO (229),
  724. EMPTY_HOWTO (230),
  725. EMPTY_HOWTO (231),
  726. EMPTY_HOWTO (232),
  727. EMPTY_HOWTO (233),
  728. EMPTY_HOWTO (234),
  729. EMPTY_HOWTO (235),
  730. EMPTY_HOWTO (236),
  731. EMPTY_HOWTO (237),
  732. EMPTY_HOWTO (238),
  733. EMPTY_HOWTO (239),
  734. EMPTY_HOWTO (240),
  735. EMPTY_HOWTO (241),
  736. EMPTY_HOWTO (242),
  737. EMPTY_HOWTO (243),
  738. EMPTY_HOWTO (244),
  739. EMPTY_HOWTO (245),
  740. EMPTY_HOWTO (246),
  741. EMPTY_HOWTO (247),
  742. EMPTY_HOWTO (248),
  743. EMPTY_HOWTO (249),
  744. EMPTY_HOWTO (250),
  745. EMPTY_HOWTO (251),
  746. EMPTY_HOWTO (252),
  747. HOWTO (R_C6000_ALIGN, /* type */
  748. 0, /* rightshift */
  749. 0, /* size (0 = byte, 1 = short, 2 = long) */
  750. 0, /* bitsize */
  751. FALSE, /* pc_relative */
  752. 0, /* bitpos */
  753. complain_overflow_dont,/* complain_on_overflow */
  754. bfd_elf_generic_reloc, /* special_function */
  755. "R_C6000_ALIGN", /* name */
  756. FALSE, /* partial_inplace */
  757. 0, /* src_mask */
  758. 0, /* dst_mask */
  759. FALSE), /* pcrel_offset */
  760. HOWTO (R_C6000_FPHEAD, /* type */
  761. 0, /* rightshift */
  762. 0, /* size (0 = byte, 1 = short, 2 = long) */
  763. 0, /* bitsize */
  764. FALSE, /* pc_relative */
  765. 0, /* bitpos */
  766. complain_overflow_dont,/* complain_on_overflow */
  767. bfd_elf_generic_reloc, /* special_function */
  768. "R_C6000_FPHEAD", /* name */
  769. FALSE, /* partial_inplace */
  770. 0, /* src_mask */
  771. 0, /* dst_mask */
  772. FALSE), /* pcrel_offset */
  773. HOWTO (R_C6000_NOCMP, /* type */
  774. 0, /* rightshift */
  775. 0, /* size (0 = byte, 1 = short, 2 = long) */
  776. 0, /* bitsize */
  777. FALSE, /* pc_relative */
  778. 0, /* bitpos */
  779. complain_overflow_dont,/* complain_on_overflow */
  780. bfd_elf_generic_reloc, /* special_function */
  781. "R_C6000_NOCMP", /* name */
  782. FALSE, /* partial_inplace */
  783. 0, /* src_mask */
  784. 0, /* dst_mask */
  785. FALSE) /* pcrel_offset */
  786. };
  787. static reloc_howto_type elf32_tic6x_howto_table_rel[] =
  788. {
  789. HOWTO (R_C6000_NONE, /* type */
  790. 0, /* rightshift */
  791. 3, /* size (0 = byte, 1 = short, 2 = long) */
  792. 0, /* bitsize */
  793. FALSE, /* pc_relative */
  794. 0, /* bitpos */
  795. complain_overflow_dont,/* complain_on_overflow */
  796. bfd_elf_generic_reloc, /* special_function */
  797. "R_C6000_NONE", /* name */
  798. TRUE, /* partial_inplace */
  799. 0, /* src_mask */
  800. 0, /* dst_mask */
  801. FALSE), /* pcrel_offset */
  802. HOWTO (R_C6000_ABS32, /* type */
  803. 0, /* rightshift */
  804. 2, /* size (0 = byte, 1 = short, 2 = long) */
  805. 32, /* bitsize */
  806. FALSE, /* pc_relative */
  807. 0, /* bitpos */
  808. complain_overflow_dont,/* complain_on_overflow */
  809. bfd_elf_generic_reloc, /* special_function */
  810. "R_C6000_ABS32", /* name */
  811. TRUE, /* partial_inplace */
  812. 0xffffffff, /* src_mask */
  813. 0xffffffff, /* dst_mask */
  814. FALSE), /* pcrel_offset */
  815. HOWTO (R_C6000_ABS16, /* type */
  816. 0, /* rightshift */
  817. 1, /* size (0 = byte, 1 = short, 2 = long) */
  818. 16, /* bitsize */
  819. FALSE, /* pc_relative */
  820. 0, /* bitpos */
  821. complain_overflow_bitfield,/* complain_on_overflow */
  822. bfd_elf_generic_reloc, /* special_function */
  823. "R_C6000_ABS16", /* name */
  824. TRUE, /* partial_inplace */
  825. 0x0000ffff, /* src_mask */
  826. 0x0000ffff, /* dst_mask */
  827. FALSE), /* pcrel_offset */
  828. HOWTO (R_C6000_ABS8, /* type */
  829. 0, /* rightshift */
  830. 0, /* size (0 = byte, 1 = short, 2 = long) */
  831. 8, /* bitsize */
  832. FALSE, /* pc_relative */
  833. 0, /* bitpos */
  834. complain_overflow_bitfield,/* complain_on_overflow */
  835. bfd_elf_generic_reloc, /* special_function */
  836. "R_C6000_ABS8", /* name */
  837. TRUE, /* partial_inplace */
  838. 0x000000ff, /* src_mask */
  839. 0x000000ff, /* dst_mask */
  840. FALSE), /* pcrel_offset */
  841. HOWTO (R_C6000_PCR_S21, /* type */
  842. 2, /* rightshift */
  843. 2, /* size (0 = byte, 1 = short, 2 = long) */
  844. 21, /* bitsize */
  845. TRUE, /* pc_relative */
  846. 7, /* bitpos */
  847. complain_overflow_signed,/* complain_on_overflow */
  848. bfd_elf_generic_reloc, /* special_function */
  849. "R_C6000_PCR_S21", /* name */
  850. TRUE, /* partial_inplace */
  851. 0x0fffff80, /* src_mask */
  852. 0x0fffff80, /* dst_mask */
  853. TRUE), /* pcrel_offset */
  854. HOWTO (R_C6000_PCR_S12, /* type */
  855. 2, /* rightshift */
  856. 2, /* size (0 = byte, 1 = short, 2 = long) */
  857. 12, /* bitsize */
  858. TRUE, /* pc_relative */
  859. 16, /* bitpos */
  860. complain_overflow_signed,/* complain_on_overflow */
  861. bfd_elf_generic_reloc, /* special_function */
  862. "R_C6000_PCR_S12", /* name */
  863. TRUE, /* partial_inplace */
  864. 0x0fff0000, /* src_mask */
  865. 0x0fff0000, /* dst_mask */
  866. TRUE), /* pcrel_offset */
  867. HOWTO (R_C6000_PCR_S10, /* type */
  868. 2, /* rightshift */
  869. 2, /* size (0 = byte, 1 = short, 2 = long) */
  870. 10, /* bitsize */
  871. TRUE, /* pc_relative */
  872. 13, /* bitpos */
  873. complain_overflow_signed,/* complain_on_overflow */
  874. bfd_elf_generic_reloc, /* special_function */
  875. "R_C6000_PCR_S10", /* name */
  876. TRUE, /* partial_inplace */
  877. 0x007fe000, /* src_mask */
  878. 0x007fe000, /* dst_mask */
  879. TRUE), /* pcrel_offset */
  880. HOWTO (R_C6000_PCR_S7, /* type */
  881. 2, /* rightshift */
  882. 2, /* size (0 = byte, 1 = short, 2 = long) */
  883. 7, /* bitsize */
  884. TRUE, /* pc_relative */
  885. 16, /* bitpos */
  886. complain_overflow_signed,/* complain_on_overflow */
  887. bfd_elf_generic_reloc, /* special_function */
  888. "R_C6000_PCR_S7", /* name */
  889. TRUE, /* partial_inplace */
  890. 0x007f0000, /* src_mask */
  891. 0x007f0000, /* dst_mask */
  892. TRUE), /* pcrel_offset */
  893. HOWTO (R_C6000_ABS_S16, /* type */
  894. 0, /* rightshift */
  895. 2, /* size (0 = byte, 1 = short, 2 = long) */
  896. 16, /* bitsize */
  897. FALSE, /* pc_relative */
  898. 7, /* bitpos */
  899. complain_overflow_signed,/* complain_on_overflow */
  900. bfd_elf_generic_reloc, /* special_function */
  901. "R_C6000_ABS_S16", /* name */
  902. TRUE, /* partial_inplace */
  903. 0x007fff80, /* src_mask */
  904. 0x007fff80, /* dst_mask */
  905. FALSE), /* pcrel_offset */
  906. HOWTO (R_C6000_ABS_L16, /* type */
  907. 0, /* rightshift */
  908. 2, /* size (0 = byte, 1 = short, 2 = long) */
  909. 16, /* bitsize */
  910. FALSE, /* pc_relative */
  911. 7, /* bitpos */
  912. complain_overflow_dont,/* complain_on_overflow */
  913. bfd_elf_generic_reloc, /* special_function */
  914. "R_C6000_ABS_L16", /* name */
  915. TRUE, /* partial_inplace */
  916. 0x007fff80, /* src_mask */
  917. 0x007fff80, /* dst_mask */
  918. FALSE), /* pcrel_offset */
  919. EMPTY_HOWTO (R_C6000_ABS_H16),
  920. HOWTO (R_C6000_SBR_U15_B, /* type */
  921. 0, /* rightshift */
  922. 2, /* size (0 = byte, 1 = short, 2 = long) */
  923. 15, /* bitsize */
  924. FALSE, /* pc_relative */
  925. 8, /* bitpos */
  926. complain_overflow_unsigned,/* complain_on_overflow */
  927. bfd_elf_generic_reloc, /* special_function */
  928. "R_C6000_SBR_U15_B", /* name */
  929. TRUE, /* partial_inplace */
  930. 0x007fff00, /* src_mask */
  931. 0x007fff00, /* dst_mask */
  932. FALSE), /* pcrel_offset */
  933. HOWTO (R_C6000_SBR_U15_H, /* type */
  934. 1, /* rightshift */
  935. 2, /* size (0 = byte, 1 = short, 2 = long) */
  936. 15, /* bitsize */
  937. FALSE, /* pc_relative */
  938. 8, /* bitpos */
  939. complain_overflow_unsigned,/* complain_on_overflow */
  940. bfd_elf_generic_reloc, /* special_function */
  941. "R_C6000_SBR_U15_H", /* name */
  942. TRUE, /* partial_inplace */
  943. 0x007fff00, /* src_mask */
  944. 0x007fff00, /* dst_mask */
  945. FALSE), /* pcrel_offset */
  946. HOWTO (R_C6000_SBR_U15_W, /* type */
  947. 2, /* rightshift */
  948. 2, /* size (0 = byte, 1 = short, 2 = long) */
  949. 15, /* bitsize */
  950. FALSE, /* pc_relative */
  951. 8, /* bitpos */
  952. complain_overflow_unsigned,/* complain_on_overflow */
  953. bfd_elf_generic_reloc, /* special_function */
  954. "R_C6000_SBR_U15_W", /* name */
  955. TRUE, /* partial_inplace */
  956. 0x007fff00, /* src_mask */
  957. 0x007fff00, /* dst_mask */
  958. FALSE), /* pcrel_offset */
  959. HOWTO (R_C6000_SBR_S16, /* type */
  960. 0, /* rightshift */
  961. 2, /* size (0 = byte, 1 = short, 2 = long) */
  962. 16, /* bitsize */
  963. FALSE, /* pc_relative */
  964. 7, /* bitpos */
  965. complain_overflow_signed,/* complain_on_overflow */
  966. bfd_elf_generic_reloc, /* special_function */
  967. "R_C6000_SBR_S16", /* name */
  968. TRUE, /* partial_inplace */
  969. 0x007fff80, /* src_mask */
  970. 0x007fff80, /* dst_mask */
  971. FALSE), /* pcrel_offset */
  972. HOWTO (R_C6000_SBR_L16_B, /* type */
  973. 0, /* rightshift */
  974. 2, /* size (0 = byte, 1 = short, 2 = long) */
  975. 16, /* bitsize */
  976. FALSE, /* pc_relative */
  977. 7, /* bitpos */
  978. complain_overflow_dont,/* complain_on_overflow */
  979. bfd_elf_generic_reloc, /* special_function */
  980. "R_C6000_SBR_L16_B", /* name */
  981. TRUE, /* partial_inplace */
  982. 0x007fff80, /* src_mask */
  983. 0x007fff80, /* dst_mask */
  984. FALSE), /* pcrel_offset */
  985. HOWTO (R_C6000_SBR_L16_H, /* type */
  986. 1, /* rightshift */
  987. 2, /* size (0 = byte, 1 = short, 2 = long) */
  988. 16, /* bitsize */
  989. FALSE, /* pc_relative */
  990. 7, /* bitpos */
  991. complain_overflow_dont,/* complain_on_overflow */
  992. bfd_elf_generic_reloc, /* special_function */
  993. "R_C6000_SBR_L16_H", /* name */
  994. TRUE, /* partial_inplace */
  995. 0x007fff80, /* src_mask */
  996. 0x007fff80, /* dst_mask */
  997. FALSE), /* pcrel_offset */
  998. HOWTO (R_C6000_SBR_L16_W, /* type */
  999. 2, /* rightshift */
  1000. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1001. 16, /* bitsize */
  1002. FALSE, /* pc_relative */
  1003. 7, /* bitpos */
  1004. complain_overflow_dont,/* complain_on_overflow */
  1005. bfd_elf_generic_reloc, /* special_function */
  1006. "R_C6000_SBR_L16_W", /* name */
  1007. TRUE, /* partial_inplace */
  1008. 0x007fff80, /* src_mask */
  1009. 0x007fff80, /* dst_mask */
  1010. FALSE), /* pcrel_offset */
  1011. EMPTY_HOWTO (R_C6000_SBR_H16_B),
  1012. EMPTY_HOWTO (R_C6000_SBR_H16_H),
  1013. EMPTY_HOWTO (R_C6000_SBR_H16_W),
  1014. HOWTO (R_C6000_SBR_GOT_U15_W, /* type */
  1015. 2, /* rightshift */
  1016. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1017. 15, /* bitsize */
  1018. FALSE, /* pc_relative */
  1019. 8, /* bitpos */
  1020. complain_overflow_unsigned,/* complain_on_overflow */
  1021. bfd_elf_generic_reloc, /* special_function */
  1022. "R_C6000_SBR_GOT_U15_W",/* name */
  1023. TRUE, /* partial_inplace */
  1024. 0x007fff00, /* src_mask */
  1025. 0x007fff00, /* dst_mask */
  1026. FALSE), /* pcrel_offset */
  1027. HOWTO (R_C6000_SBR_GOT_L16_W, /* type */
  1028. 2, /* rightshift */
  1029. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1030. 16, /* bitsize */
  1031. FALSE, /* pc_relative */
  1032. 7, /* bitpos */
  1033. complain_overflow_dont,/* complain_on_overflow */
  1034. bfd_elf_generic_reloc, /* special_function */
  1035. "R_C6000_SBR_GOT_L16_W",/* name */
  1036. TRUE, /* partial_inplace */
  1037. 0x007fff80, /* src_mask */
  1038. 0x007fff80, /* dst_mask */
  1039. FALSE), /* pcrel_offset */
  1040. EMPTY_HOWTO (R_C6000_SBR_GOT_H16_W),
  1041. HOWTO (R_C6000_DSBT_INDEX, /* type */
  1042. 0, /* rightshift */
  1043. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1044. 15, /* bitsize */
  1045. FALSE, /* pc_relative */
  1046. 8, /* bitpos */
  1047. complain_overflow_unsigned,/* complain_on_overflow */
  1048. bfd_elf_generic_reloc, /* special_function */
  1049. "R_C6000_DSBT_INDEX", /* name */
  1050. TRUE, /* partial_inplace */
  1051. 0, /* src_mask */
  1052. 0x007fff00, /* dst_mask */
  1053. FALSE), /* pcrel_offset */
  1054. HOWTO (R_C6000_PREL31, /* type */
  1055. 1, /* rightshift */
  1056. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1057. 31, /* bitsize */
  1058. TRUE, /* pc_relative */
  1059. 0, /* bitpos */
  1060. complain_overflow_dont,/* complain_on_overflow */
  1061. bfd_elf_generic_reloc, /* special_function */
  1062. "R_C6000_PREL31", /* name */
  1063. TRUE, /* partial_inplace */
  1064. 0, /* src_mask */
  1065. 0x7fffffff, /* dst_mask */
  1066. TRUE), /* pcrel_offset */
  1067. HOWTO (R_C6000_COPY, /* type */
  1068. 0, /* rightshift */
  1069. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1070. 32, /* bitsize */
  1071. FALSE, /* pc_relative */
  1072. 0, /* bitpos */
  1073. complain_overflow_dont,/* complain_on_overflow */
  1074. bfd_elf_generic_reloc, /* special_function */
  1075. "R_C6000_COPY", /* name */
  1076. TRUE, /* partial_inplace */
  1077. 0, /* src_mask */
  1078. 0xffffffff, /* dst_mask */
  1079. FALSE), /* pcrel_offset */
  1080. HOWTO (R_C6000_JUMP_SLOT, /* type */
  1081. 0, /* rightshift */
  1082. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1083. 32, /* bitsize */
  1084. FALSE, /* pc_relative */
  1085. 0, /* bitpos */
  1086. complain_overflow_dont,/* complain_on_overflow */
  1087. bfd_elf_generic_reloc, /* special_function */
  1088. "R_C6000_JUMP_SLOT", /* name */
  1089. FALSE, /* partial_inplace */
  1090. 0, /* src_mask */
  1091. 0xffffffff, /* dst_mask */
  1092. FALSE), /* pcrel_offset */
  1093. HOWTO (R_C6000_EHTYPE, /* type */
  1094. 0, /* rightshift */
  1095. 2, /* size (0 = byte, 1 = short, 2 = long) */
  1096. 32, /* bitsize */
  1097. FALSE, /* pc_relative */
  1098. 0, /* bitpos */
  1099. complain_overflow_dont,/* complain_on_overflow */
  1100. bfd_elf_generic_reloc, /* special_function */
  1101. "R_C6000_EHTYPE", /* name */
  1102. FALSE, /* partial_inplace */
  1103. 0, /* src_mask */
  1104. 0xffffffff, /* dst_mask */
  1105. FALSE), /* pcrel_offset */
  1106. EMPTY_HOWTO (R_C6000_PCR_H16),
  1107. EMPTY_HOWTO (R_C6000_PCR_L16),
  1108. EMPTY_HOWTO (31),
  1109. EMPTY_HOWTO (32),
  1110. EMPTY_HOWTO (33),
  1111. EMPTY_HOWTO (34),
  1112. EMPTY_HOWTO (35),
  1113. EMPTY_HOWTO (36),
  1114. EMPTY_HOWTO (37),
  1115. EMPTY_HOWTO (38),
  1116. EMPTY_HOWTO (39),
  1117. EMPTY_HOWTO (40),
  1118. EMPTY_HOWTO (41),
  1119. EMPTY_HOWTO (42),
  1120. EMPTY_HOWTO (43),
  1121. EMPTY_HOWTO (44),
  1122. EMPTY_HOWTO (45),
  1123. EMPTY_HOWTO (46),
  1124. EMPTY_HOWTO (47),
  1125. EMPTY_HOWTO (48),
  1126. EMPTY_HOWTO (49),
  1127. EMPTY_HOWTO (50),
  1128. EMPTY_HOWTO (51),
  1129. EMPTY_HOWTO (52),
  1130. EMPTY_HOWTO (53),
  1131. EMPTY_HOWTO (54),
  1132. EMPTY_HOWTO (55),
  1133. EMPTY_HOWTO (56),
  1134. EMPTY_HOWTO (57),
  1135. EMPTY_HOWTO (58),
  1136. EMPTY_HOWTO (59),
  1137. EMPTY_HOWTO (60),
  1138. EMPTY_HOWTO (61),
  1139. EMPTY_HOWTO (62),
  1140. EMPTY_HOWTO (63),
  1141. EMPTY_HOWTO (64),
  1142. EMPTY_HOWTO (65),
  1143. EMPTY_HOWTO (66),
  1144. EMPTY_HOWTO (67),
  1145. EMPTY_HOWTO (68),
  1146. EMPTY_HOWTO (69),
  1147. EMPTY_HOWTO (70),
  1148. EMPTY_HOWTO (71),
  1149. EMPTY_HOWTO (72),
  1150. EMPTY_HOWTO (73),
  1151. EMPTY_HOWTO (74),
  1152. EMPTY_HOWTO (75),
  1153. EMPTY_HOWTO (76),
  1154. EMPTY_HOWTO (77),
  1155. EMPTY_HOWTO (78),
  1156. EMPTY_HOWTO (79),
  1157. EMPTY_HOWTO (80),
  1158. EMPTY_HOWTO (81),
  1159. EMPTY_HOWTO (82),
  1160. EMPTY_HOWTO (83),
  1161. EMPTY_HOWTO (84),
  1162. EMPTY_HOWTO (85),
  1163. EMPTY_HOWTO (86),
  1164. EMPTY_HOWTO (87),
  1165. EMPTY_HOWTO (88),
  1166. EMPTY_HOWTO (89),
  1167. EMPTY_HOWTO (90),
  1168. EMPTY_HOWTO (91),
  1169. EMPTY_HOWTO (92),
  1170. EMPTY_HOWTO (93),
  1171. EMPTY_HOWTO (94),
  1172. EMPTY_HOWTO (95),
  1173. EMPTY_HOWTO (96),
  1174. EMPTY_HOWTO (97),
  1175. EMPTY_HOWTO (98),
  1176. EMPTY_HOWTO (99),
  1177. EMPTY_HOWTO (100),
  1178. EMPTY_HOWTO (101),
  1179. EMPTY_HOWTO (102),
  1180. EMPTY_HOWTO (103),
  1181. EMPTY_HOWTO (104),
  1182. EMPTY_HOWTO (105),
  1183. EMPTY_HOWTO (106),
  1184. EMPTY_HOWTO (107),
  1185. EMPTY_HOWTO (108),
  1186. EMPTY_HOWTO (109),
  1187. EMPTY_HOWTO (110),
  1188. EMPTY_HOWTO (111),
  1189. EMPTY_HOWTO (112),
  1190. EMPTY_HOWTO (113),
  1191. EMPTY_HOWTO (114),
  1192. EMPTY_HOWTO (115),
  1193. EMPTY_HOWTO (116),
  1194. EMPTY_HOWTO (117),
  1195. EMPTY_HOWTO (118),
  1196. EMPTY_HOWTO (119),
  1197. EMPTY_HOWTO (120),
  1198. EMPTY_HOWTO (121),
  1199. EMPTY_HOWTO (122),
  1200. EMPTY_HOWTO (123),
  1201. EMPTY_HOWTO (124),
  1202. EMPTY_HOWTO (125),
  1203. EMPTY_HOWTO (126),
  1204. EMPTY_HOWTO (127),
  1205. EMPTY_HOWTO (128),
  1206. EMPTY_HOWTO (129),
  1207. EMPTY_HOWTO (130),
  1208. EMPTY_HOWTO (131),
  1209. EMPTY_HOWTO (132),
  1210. EMPTY_HOWTO (133),
  1211. EMPTY_HOWTO (134),
  1212. EMPTY_HOWTO (135),
  1213. EMPTY_HOWTO (136),
  1214. EMPTY_HOWTO (137),
  1215. EMPTY_HOWTO (138),
  1216. EMPTY_HOWTO (139),
  1217. EMPTY_HOWTO (140),
  1218. EMPTY_HOWTO (141),
  1219. EMPTY_HOWTO (142),
  1220. EMPTY_HOWTO (143),
  1221. EMPTY_HOWTO (144),
  1222. EMPTY_HOWTO (145),
  1223. EMPTY_HOWTO (146),
  1224. EMPTY_HOWTO (147),
  1225. EMPTY_HOWTO (148),
  1226. EMPTY_HOWTO (149),
  1227. EMPTY_HOWTO (150),
  1228. EMPTY_HOWTO (151),
  1229. EMPTY_HOWTO (152),
  1230. EMPTY_HOWTO (153),
  1231. EMPTY_HOWTO (154),
  1232. EMPTY_HOWTO (155),
  1233. EMPTY_HOWTO (156),
  1234. EMPTY_HOWTO (157),
  1235. EMPTY_HOWTO (158),
  1236. EMPTY_HOWTO (159),
  1237. EMPTY_HOWTO (160),
  1238. EMPTY_HOWTO (161),
  1239. EMPTY_HOWTO (162),
  1240. EMPTY_HOWTO (163),
  1241. EMPTY_HOWTO (164),
  1242. EMPTY_HOWTO (165),
  1243. EMPTY_HOWTO (166),
  1244. EMPTY_HOWTO (167),
  1245. EMPTY_HOWTO (168),
  1246. EMPTY_HOWTO (169),
  1247. EMPTY_HOWTO (170),
  1248. EMPTY_HOWTO (171),
  1249. EMPTY_HOWTO (172),
  1250. EMPTY_HOWTO (173),
  1251. EMPTY_HOWTO (174),
  1252. EMPTY_HOWTO (175),
  1253. EMPTY_HOWTO (176),
  1254. EMPTY_HOWTO (177),
  1255. EMPTY_HOWTO (178),
  1256. EMPTY_HOWTO (179),
  1257. EMPTY_HOWTO (180),
  1258. EMPTY_HOWTO (181),
  1259. EMPTY_HOWTO (182),
  1260. EMPTY_HOWTO (183),
  1261. EMPTY_HOWTO (184),
  1262. EMPTY_HOWTO (185),
  1263. EMPTY_HOWTO (186),
  1264. EMPTY_HOWTO (187),
  1265. EMPTY_HOWTO (188),
  1266. EMPTY_HOWTO (189),
  1267. EMPTY_HOWTO (190),
  1268. EMPTY_HOWTO (191),
  1269. EMPTY_HOWTO (192),
  1270. EMPTY_HOWTO (193),
  1271. EMPTY_HOWTO (194),
  1272. EMPTY_HOWTO (195),
  1273. EMPTY_HOWTO (196),
  1274. EMPTY_HOWTO (197),
  1275. EMPTY_HOWTO (198),
  1276. EMPTY_HOWTO (199),
  1277. EMPTY_HOWTO (200),
  1278. EMPTY_HOWTO (201),
  1279. EMPTY_HOWTO (202),
  1280. EMPTY_HOWTO (203),
  1281. EMPTY_HOWTO (204),
  1282. EMPTY_HOWTO (205),
  1283. EMPTY_HOWTO (206),
  1284. EMPTY_HOWTO (207),
  1285. EMPTY_HOWTO (208),
  1286. EMPTY_HOWTO (209),
  1287. EMPTY_HOWTO (210),
  1288. EMPTY_HOWTO (211),
  1289. EMPTY_HOWTO (212),
  1290. EMPTY_HOWTO (213),
  1291. EMPTY_HOWTO (214),
  1292. EMPTY_HOWTO (215),
  1293. EMPTY_HOWTO (216),
  1294. EMPTY_HOWTO (217),
  1295. EMPTY_HOWTO (218),
  1296. EMPTY_HOWTO (219),
  1297. EMPTY_HOWTO (220),
  1298. EMPTY_HOWTO (221),
  1299. EMPTY_HOWTO (222),
  1300. EMPTY_HOWTO (223),
  1301. EMPTY_HOWTO (224),
  1302. EMPTY_HOWTO (225),
  1303. EMPTY_HOWTO (226),
  1304. EMPTY_HOWTO (227),
  1305. EMPTY_HOWTO (228),
  1306. EMPTY_HOWTO (229),
  1307. EMPTY_HOWTO (230),
  1308. EMPTY_HOWTO (231),
  1309. EMPTY_HOWTO (232),
  1310. EMPTY_HOWTO (233),
  1311. EMPTY_HOWTO (234),
  1312. EMPTY_HOWTO (235),
  1313. EMPTY_HOWTO (236),
  1314. EMPTY_HOWTO (237),
  1315. EMPTY_HOWTO (238),
  1316. EMPTY_HOWTO (239),
  1317. EMPTY_HOWTO (240),
  1318. EMPTY_HOWTO (241),
  1319. EMPTY_HOWTO (242),
  1320. EMPTY_HOWTO (243),
  1321. EMPTY_HOWTO (244),
  1322. EMPTY_HOWTO (245),
  1323. EMPTY_HOWTO (246),
  1324. EMPTY_HOWTO (247),
  1325. EMPTY_HOWTO (248),
  1326. EMPTY_HOWTO (249),
  1327. EMPTY_HOWTO (250),
  1328. EMPTY_HOWTO (251),
  1329. EMPTY_HOWTO (252),
  1330. HOWTO (R_C6000_ALIGN, /* type */
  1331. 0, /* rightshift */
  1332. 0, /* size (0 = byte, 1 = short, 2 = long) */
  1333. 0, /* bitsize */
  1334. FALSE, /* pc_relative */
  1335. 0, /* bitpos */
  1336. complain_overflow_dont,/* complain_on_overflow */
  1337. bfd_elf_generic_reloc, /* special_function */
  1338. "R_C6000_ALIGN", /* name */
  1339. TRUE, /* partial_inplace */
  1340. 0, /* src_mask */
  1341. 0, /* dst_mask */
  1342. FALSE), /* pcrel_offset */
  1343. HOWTO (R_C6000_FPHEAD, /* type */
  1344. 0, /* rightshift */
  1345. 0, /* size (0 = byte, 1 = short, 2 = long) */
  1346. 0, /* bitsize */
  1347. FALSE, /* pc_relative */
  1348. 0, /* bitpos */
  1349. complain_overflow_dont,/* complain_on_overflow */
  1350. bfd_elf_generic_reloc, /* special_function */
  1351. "R_C6000_FPHEAD", /* name */
  1352. TRUE, /* partial_inplace */
  1353. 0, /* src_mask */
  1354. 0, /* dst_mask */
  1355. FALSE), /* pcrel_offset */
  1356. HOWTO (R_C6000_NOCMP, /* type */
  1357. 0, /* rightshift */
  1358. 0, /* size (0 = byte, 1 = short, 2 = long) */
  1359. 0, /* bitsize */
  1360. FALSE, /* pc_relative */
  1361. 0, /* bitpos */
  1362. complain_overflow_dont,/* complain_on_overflow */
  1363. bfd_elf_generic_reloc, /* special_function */
  1364. "R_C6000_NOCMP", /* name */
  1365. TRUE, /* partial_inplace */
  1366. 0, /* src_mask */
  1367. 0, /* dst_mask */
  1368. FALSE) /* pcrel_offset */
  1369. };
  1370. /* Map BFD relocations to ELF relocations. */
  1371. typedef struct
  1372. {
  1373. bfd_reloc_code_real_type bfd_reloc_val;
  1374. enum elf_tic6x_reloc_type elf_reloc_val;
  1375. } tic6x_reloc_map;
  1376. static const tic6x_reloc_map elf32_tic6x_reloc_map[] =
  1377. {
  1378. { BFD_RELOC_NONE, R_C6000_NONE },
  1379. { BFD_RELOC_32, R_C6000_ABS32 },
  1380. { BFD_RELOC_16, R_C6000_ABS16 },
  1381. { BFD_RELOC_8, R_C6000_ABS8 },
  1382. { BFD_RELOC_C6000_PCR_S21, R_C6000_PCR_S21 },
  1383. { BFD_RELOC_C6000_PCR_S12, R_C6000_PCR_S12 },
  1384. { BFD_RELOC_C6000_PCR_S10, R_C6000_PCR_S10 },
  1385. { BFD_RELOC_C6000_PCR_S7, R_C6000_PCR_S7 },
  1386. { BFD_RELOC_C6000_ABS_S16, R_C6000_ABS_S16 },
  1387. { BFD_RELOC_C6000_ABS_L16, R_C6000_ABS_L16 },
  1388. { BFD_RELOC_C6000_ABS_H16, R_C6000_ABS_H16 },
  1389. { BFD_RELOC_C6000_SBR_U15_B, R_C6000_SBR_U15_B },
  1390. { BFD_RELOC_C6000_SBR_U15_H, R_C6000_SBR_U15_H },
  1391. { BFD_RELOC_C6000_SBR_U15_W, R_C6000_SBR_U15_W },
  1392. { BFD_RELOC_C6000_SBR_S16, R_C6000_SBR_S16 },
  1393. { BFD_RELOC_C6000_SBR_L16_B, R_C6000_SBR_L16_B },
  1394. { BFD_RELOC_C6000_SBR_L16_H, R_C6000_SBR_L16_H },
  1395. { BFD_RELOC_C6000_SBR_L16_W, R_C6000_SBR_L16_W },
  1396. { BFD_RELOC_C6000_SBR_H16_B, R_C6000_SBR_H16_B },
  1397. { BFD_RELOC_C6000_SBR_H16_H, R_C6000_SBR_H16_H },
  1398. { BFD_RELOC_C6000_SBR_H16_W, R_C6000_SBR_H16_W },
  1399. { BFD_RELOC_C6000_SBR_GOT_U15_W, R_C6000_SBR_GOT_U15_W },
  1400. { BFD_RELOC_C6000_SBR_GOT_L16_W, R_C6000_SBR_GOT_L16_W },
  1401. { BFD_RELOC_C6000_SBR_GOT_H16_W, R_C6000_SBR_GOT_H16_W },
  1402. { BFD_RELOC_C6000_DSBT_INDEX, R_C6000_DSBT_INDEX },
  1403. { BFD_RELOC_C6000_PREL31, R_C6000_PREL31 },
  1404. { BFD_RELOC_C6000_COPY, R_C6000_COPY },
  1405. { BFD_RELOC_C6000_JUMP_SLOT, R_C6000_JUMP_SLOT },
  1406. { BFD_RELOC_C6000_EHTYPE, R_C6000_EHTYPE },
  1407. { BFD_RELOC_C6000_PCR_H16, R_C6000_PCR_H16 },
  1408. { BFD_RELOC_C6000_PCR_L16, R_C6000_PCR_L16 },
  1409. { BFD_RELOC_C6000_ALIGN, R_C6000_ALIGN },
  1410. { BFD_RELOC_C6000_FPHEAD, R_C6000_FPHEAD },
  1411. { BFD_RELOC_C6000_NOCMP, R_C6000_NOCMP }
  1412. };
  1413. static reloc_howto_type *
  1414. elf32_tic6x_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code)
  1415. {
  1416. unsigned int i;
  1417. for (i = 0; i < ARRAY_SIZE (elf32_tic6x_reloc_map); i++)
  1418. if (elf32_tic6x_reloc_map[i].bfd_reloc_val == code)
  1419. {
  1420. enum elf_tic6x_reloc_type elf_reloc_val;
  1421. reloc_howto_type *howto;
  1422. elf_reloc_val = elf32_tic6x_reloc_map[i].elf_reloc_val;
  1423. if (elf32_tic6x_tdata (abfd)->use_rela_p)
  1424. howto = &elf32_tic6x_howto_table[elf_reloc_val];
  1425. else
  1426. howto = &elf32_tic6x_howto_table_rel[elf_reloc_val];
  1427. /* Some relocations are RELA-only; do not return them for
  1428. REL. */
  1429. if (howto->name == NULL)
  1430. howto = NULL;
  1431. return howto;
  1432. }
  1433. return NULL;
  1434. }
  1435. static reloc_howto_type *
  1436. elf32_tic6x_reloc_name_lookup (bfd *abfd, const char *r_name)
  1437. {
  1438. if (elf32_tic6x_tdata (abfd)->use_rela_p)
  1439. {
  1440. unsigned int i;
  1441. for (i = 0; i < ARRAY_SIZE (elf32_tic6x_howto_table); i++)
  1442. if (elf32_tic6x_howto_table[i].name != NULL
  1443. && strcasecmp (elf32_tic6x_howto_table[i].name, r_name) == 0)
  1444. return &elf32_tic6x_howto_table[i];
  1445. }
  1446. else
  1447. {
  1448. unsigned int i;
  1449. for (i = 0; i < ARRAY_SIZE (elf32_tic6x_howto_table_rel); i++)
  1450. if (elf32_tic6x_howto_table_rel[i].name != NULL
  1451. && strcasecmp (elf32_tic6x_howto_table_rel[i].name, r_name) == 0)
  1452. return &elf32_tic6x_howto_table_rel[i];
  1453. }
  1454. return NULL;
  1455. }
  1456. static void
  1457. elf32_tic6x_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
  1458. Elf_Internal_Rela *elf_reloc)
  1459. {
  1460. unsigned int r_type;
  1461. r_type = ELF32_R_TYPE (elf_reloc->r_info);
  1462. if (r_type >= ARRAY_SIZE (elf32_tic6x_howto_table))
  1463. bfd_reloc->howto = NULL;
  1464. else
  1465. bfd_reloc->howto = &elf32_tic6x_howto_table[r_type];
  1466. }
  1467. static void
  1468. elf32_tic6x_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
  1469. Elf_Internal_Rela *elf_reloc)
  1470. {
  1471. unsigned int r_type;
  1472. r_type = ELF32_R_TYPE (elf_reloc->r_info);
  1473. if (r_type >= ARRAY_SIZE (elf32_tic6x_howto_table_rel))
  1474. bfd_reloc->howto = NULL;
  1475. else
  1476. bfd_reloc->howto = &elf32_tic6x_howto_table_rel[r_type];
  1477. }
  1478. void
  1479. elf32_tic6x_set_use_rela_p (bfd *abfd, bfd_boolean use_rela_p)
  1480. {
  1481. elf32_tic6x_tdata (abfd)->use_rela_p = use_rela_p;
  1482. }
  1483. /* Create an entry in a C6X ELF linker hash table. */
  1484. static struct bfd_hash_entry *
  1485. elf32_tic6x_link_hash_newfunc (struct bfd_hash_entry *entry,
  1486. struct bfd_hash_table *table,
  1487. const char *string)
  1488. {
  1489. /* Allocate the structure if it has not already been allocated by a
  1490. subclass. */
  1491. if (entry == NULL)
  1492. {
  1493. entry = bfd_hash_allocate (table,
  1494. sizeof (struct elf32_tic6x_link_hash_entry));
  1495. if (entry == NULL)
  1496. return entry;
  1497. }
  1498. /* Call the allocation method of the superclass. */
  1499. entry = _bfd_elf_link_hash_newfunc (entry, table, string);
  1500. if (entry != NULL)
  1501. {
  1502. struct elf32_tic6x_link_hash_entry *eh;
  1503. eh = (struct elf32_tic6x_link_hash_entry *) entry;
  1504. eh->dyn_relocs = NULL;
  1505. }
  1506. return entry;
  1507. }
  1508. /* Create a C6X ELF linker hash table. */
  1509. static struct bfd_link_hash_table *
  1510. elf32_tic6x_link_hash_table_create (bfd *abfd)
  1511. {
  1512. struct elf32_tic6x_link_hash_table *ret;
  1513. bfd_size_type amt = sizeof (struct elf32_tic6x_link_hash_table);
  1514. ret = bfd_zmalloc (amt);
  1515. if (ret == NULL)
  1516. return NULL;
  1517. if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd,
  1518. elf32_tic6x_link_hash_newfunc,
  1519. sizeof (struct elf32_tic6x_link_hash_entry),
  1520. TIC6X_ELF_DATA))
  1521. {
  1522. free (ret);
  1523. return NULL;
  1524. }
  1525. ret->obfd = abfd;
  1526. ret->elf.is_relocatable_executable = 1;
  1527. return &ret->elf.root;
  1528. }
  1529. static bfd_boolean
  1530. elf32_tic6x_final_link (bfd *abfd, struct bfd_link_info *info)
  1531. {
  1532. if (bfd_link_pic (info))
  1533. {
  1534. obj_attribute *out_attr;
  1535. out_attr = elf_known_obj_attributes_proc (abfd);
  1536. if (out_attr[Tag_ABI_PIC].i == 0)
  1537. {
  1538. _bfd_error_handler (_("warning: generating a shared library "
  1539. "containing non-PIC code"));
  1540. }
  1541. if (out_attr[Tag_ABI_PID].i == 0)
  1542. {
  1543. _bfd_error_handler (_("warning: generating a shared library "
  1544. "containing non-PID code"));
  1545. }
  1546. }
  1547. /* Invoke the regular ELF backend linker to do all the work. */
  1548. if (!bfd_elf_final_link (abfd, info))
  1549. return FALSE;
  1550. return TRUE;
  1551. }
  1552. /* Called to pass PARAMS to the backend. We store them in the hash table
  1553. associated with INFO. */
  1554. void
  1555. elf32_tic6x_setup (struct bfd_link_info *info,
  1556. struct elf32_tic6x_params *params)
  1557. {
  1558. struct elf32_tic6x_link_hash_table *htab = elf32_tic6x_hash_table (info);
  1559. htab->params = *params;
  1560. }
  1561. /* Determine if we're dealing with a DSBT object. */
  1562. static bfd_boolean
  1563. elf32_tic6x_using_dsbt (bfd *abfd)
  1564. {
  1565. return bfd_elf_get_obj_attr_int (abfd, OBJ_ATTR_PROC,
  1566. Tag_ABI_DSBT);
  1567. }
  1568. /* Create .plt, .rela.plt, .got, .got.plt, .rela.got and .dsbt
  1569. sections in DYNOBJ, and set up shortcuts to them in our hash
  1570. table. */
  1571. static bfd_boolean
  1572. elf32_tic6x_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
  1573. {
  1574. struct elf32_tic6x_link_hash_table *htab;
  1575. flagword flags;
  1576. htab = elf32_tic6x_hash_table (info);
  1577. if (htab == NULL)
  1578. return FALSE;
  1579. if (!_bfd_elf_create_dynamic_sections (dynobj, info))
  1580. return FALSE;
  1581. /* Create .dsbt */
  1582. flags = (SEC_ALLOC | SEC_LOAD
  1583. | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
  1584. htab->dsbt = bfd_make_section_anyway_with_flags (dynobj, ".dsbt",
  1585. flags);
  1586. if (htab->dsbt == NULL
  1587. || ! bfd_set_section_alignment (dynobj, htab->dsbt, 2)
  1588. || ! bfd_set_section_alignment (dynobj, htab->elf.splt, 5))
  1589. return FALSE;
  1590. htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
  1591. if (!bfd_link_pic (info))
  1592. htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
  1593. if (!htab->sdynbss
  1594. || (!bfd_link_pic (info) && !htab->srelbss))
  1595. abort ();
  1596. return TRUE;
  1597. }
  1598. static bfd_boolean
  1599. elf32_tic6x_mkobject (bfd *abfd)
  1600. {
  1601. bfd_boolean ret;
  1602. ret = bfd_elf_allocate_object (abfd, sizeof (struct elf32_tic6x_obj_tdata),
  1603. TIC6X_ELF_DATA);
  1604. if (ret)
  1605. elf32_tic6x_set_use_rela_p (abfd, TRUE);
  1606. return ret;
  1607. }
  1608. /* Install relocation RELA into section SRELA, incrementing its
  1609. reloc_count. */
  1610. static void
  1611. elf32_tic6x_install_rela (bfd *output_bfd, asection *srela,
  1612. Elf_Internal_Rela *rela)
  1613. {
  1614. bfd_byte *loc;
  1615. bfd_vma off = srela->reloc_count++ * sizeof (Elf32_External_Rela);
  1616. loc = srela->contents + off;
  1617. BFD_ASSERT (off < srela->size);
  1618. bfd_elf32_swap_reloca_out (output_bfd, rela, loc);
  1619. }
  1620. /* Create a dynamic reloc against the GOT at offset OFFSET. The contents
  1621. of the GOT at this offset have been initialized with the relocation. */
  1622. static void
  1623. elf32_tic6x_make_got_dynreloc (bfd *output_bfd,
  1624. struct elf32_tic6x_link_hash_table *htab,
  1625. asection *sym_sec, bfd_vma offset)
  1626. {
  1627. asection *sgot = htab->elf.sgot;
  1628. Elf_Internal_Rela outrel;
  1629. int dynindx;
  1630. outrel.r_offset = sgot->output_section->vma + sgot->output_offset + offset;
  1631. outrel.r_addend = bfd_get_32 (output_bfd, sgot->contents + offset);
  1632. if (sym_sec && sym_sec->output_section
  1633. && ! bfd_is_abs_section (sym_sec->output_section)
  1634. && ! bfd_is_und_section (sym_sec->output_section))
  1635. {
  1636. dynindx = elf_section_data (sym_sec->output_section)->dynindx;
  1637. outrel.r_addend -= sym_sec->output_section->vma;
  1638. }
  1639. else
  1640. {
  1641. dynindx = 0;
  1642. }
  1643. outrel.r_info = ELF32_R_INFO (dynindx, R_C6000_ABS32);
  1644. elf32_tic6x_install_rela (output_bfd, htab->elf.srelgot, &outrel);
  1645. }
  1646. /* Finish up dynamic symbol handling. We set the contents of various
  1647. dynamic sections here. */
  1648. static bfd_boolean
  1649. elf32_tic6x_finish_dynamic_symbol (bfd * output_bfd,
  1650. struct bfd_link_info *info,
  1651. struct elf_link_hash_entry *h,
  1652. Elf_Internal_Sym * sym)
  1653. {
  1654. bfd *dynobj;
  1655. struct elf32_tic6x_link_hash_table *htab;
  1656. htab = elf32_tic6x_hash_table (info);
  1657. dynobj = htab->elf.dynobj;
  1658. if (h->plt.offset != (bfd_vma) -1)
  1659. {
  1660. bfd_vma plt_index;
  1661. bfd_vma got_section_offset, got_dp_offset, rela_offset;
  1662. Elf_Internal_Rela rela;
  1663. bfd_byte *loc;
  1664. asection *plt, *gotplt, *relplt;
  1665. const struct elf_backend_data *bed;
  1666. bed = get_elf_backend_data (output_bfd);
  1667. BFD_ASSERT (htab->elf.splt != NULL);
  1668. plt = htab->elf.splt;
  1669. gotplt = htab->elf.sgotplt;
  1670. relplt = htab->elf.srelplt;
  1671. /* This symbol has an entry in the procedure linkage table. Set
  1672. it up. */
  1673. if ((h->dynindx == -1
  1674. && !((h->forced_local || bfd_link_executable (info))
  1675. && h->def_regular
  1676. && h->type == STT_GNU_IFUNC))
  1677. || plt == NULL
  1678. || gotplt == NULL
  1679. || relplt == NULL)
  1680. abort ();
  1681. /* Get the index in the procedure linkage table which
  1682. corresponds to this symbol. This is the index of this symbol
  1683. in all the symbols for which we are making plt entries. The
  1684. first entry in the procedure linkage table is reserved.
  1685. Get the offset into the .got table of the entry that
  1686. corresponds to this function. Each .got entry is 4 bytes.
  1687. The first three are reserved.
  1688. For static executables, we don't reserve anything. */
  1689. plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
  1690. got_section_offset = plt_index + bed->got_header_size / 4;
  1691. got_dp_offset = got_section_offset + htab->params.dsbt_size;
  1692. rela_offset = plt_index * sizeof (Elf32_External_Rela);
  1693. got_section_offset *= 4;
  1694. /* Fill in the entry in the procedure linkage table. */
  1695. /* ldw .d2t2 *+B14($GOT(f)), b2 */
  1696. bfd_put_32 (output_bfd, got_dp_offset << 8 | 0x0100006e,
  1697. plt->contents + h->plt.offset);
  1698. /* mvk .s2 low(rela_offset), b0 */
  1699. bfd_put_32 (output_bfd, (rela_offset & 0xffff) << 7 | 0x0000002a,
  1700. plt->contents + h->plt.offset + 4);
  1701. /* mvkh .s2 high(rela_offset), b0 */
  1702. bfd_put_32 (output_bfd, ((rela_offset >> 16) & 0xffff) << 7 | 0x0000006a,
  1703. plt->contents + h->plt.offset + 8);
  1704. /* nop 2 */
  1705. bfd_put_32 (output_bfd, 0x00002000,
  1706. plt->contents + h->plt.offset + 12);
  1707. /* b .s2 b2 */
  1708. bfd_put_32 (output_bfd, 0x00080362,
  1709. plt->contents + h->plt.offset + 16);
  1710. /* nop 5 */
  1711. bfd_put_32 (output_bfd, 0x00008000,
  1712. plt->contents + h->plt.offset + 20);
  1713. /* Fill in the entry in the global offset table. */
  1714. bfd_put_32 (output_bfd,
  1715. (plt->output_section->vma + plt->output_offset),
  1716. gotplt->contents + got_section_offset);
  1717. /* Fill in the entry in the .rel.plt section. */
  1718. rela.r_offset = (gotplt->output_section->vma
  1719. + gotplt->output_offset
  1720. + got_section_offset);
  1721. rela.r_info = ELF32_R_INFO (h->dynindx, R_C6000_JUMP_SLOT);
  1722. rela.r_addend = 0;
  1723. loc = relplt->contents + rela_offset;
  1724. bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
  1725. if (!h->def_regular)
  1726. {
  1727. /* Mark the symbol as undefined, rather than as defined in
  1728. the .plt section. */
  1729. sym->st_shndx = SHN_UNDEF;
  1730. sym->st_value = 0;
  1731. }
  1732. }
  1733. if (h->got.offset != (bfd_vma) -1)
  1734. {
  1735. asection *sgot;
  1736. asection *srela;
  1737. /* This symbol has an entry in the global offset table.
  1738. Set it up. */
  1739. sgot = bfd_get_linker_section (dynobj, ".got");
  1740. srela = bfd_get_linker_section (dynobj, ".rela.got");
  1741. BFD_ASSERT (sgot != NULL && srela != NULL);
  1742. /* If this is a -Bsymbolic link, and the symbol is defined
  1743. locally, we just want to emit a RELATIVE reloc. Likewise if
  1744. the symbol was forced to be local because of a version file.
  1745. The entry in the global offset table will already have been
  1746. initialized in the relocate_section function. */
  1747. if (bfd_link_pic (info)
  1748. && (SYMBOLIC_BIND (info, h)
  1749. || h->dynindx == -1 || h->forced_local) && h->def_regular)
  1750. {
  1751. asection *s = h->root.u.def.section;
  1752. elf32_tic6x_make_got_dynreloc (output_bfd, htab, s,
  1753. h->got.offset & ~(bfd_vma) 1);
  1754. }
  1755. else
  1756. {
  1757. Elf_Internal_Rela outrel;
  1758. bfd_put_32 (output_bfd, (bfd_vma) 0,
  1759. sgot->contents + (h->got.offset & ~(bfd_vma) 1));
  1760. outrel.r_offset = (sgot->output_section->vma
  1761. + sgot->output_offset
  1762. + (h->got.offset & ~(bfd_vma) 1));
  1763. outrel.r_info = ELF32_R_INFO (h->dynindx, R_C6000_ABS32);
  1764. outrel.r_addend = 0;
  1765. elf32_tic6x_install_rela (output_bfd, srela, &outrel);
  1766. }
  1767. }
  1768. if (h->needs_copy)
  1769. {
  1770. Elf_Internal_Rela rel;
  1771. /* This symbol needs a copy reloc. Set it up. */
  1772. if (h->dynindx == -1
  1773. || (h->root.type != bfd_link_hash_defined
  1774. && h->root.type != bfd_link_hash_defweak)
  1775. || htab->srelbss == NULL)
  1776. abort ();
  1777. rel.r_offset = (h->root.u.def.value
  1778. + h->root.u.def.section->output_section->vma
  1779. + h->root.u.def.section->output_offset);
  1780. rel.r_info = ELF32_R_INFO (h->dynindx, R_C6000_COPY);
  1781. rel.r_addend = 0;
  1782. elf32_tic6x_install_rela (output_bfd, htab->srelbss, &rel);
  1783. }
  1784. /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
  1785. if (h == elf_hash_table (info)->hdynamic
  1786. || h == elf_hash_table (info)->hgot)
  1787. sym->st_shndx = SHN_ABS;
  1788. return TRUE;
  1789. }
  1790. /* Unwinding tables are not referenced directly. This pass marks them as
  1791. required if the corresponding code section is marked. */
  1792. static bfd_boolean
  1793. elf32_tic6x_gc_mark_extra_sections (struct bfd_link_info *info,
  1794. elf_gc_mark_hook_fn gc_mark_hook)
  1795. {
  1796. bfd *sub;
  1797. Elf_Internal_Shdr **elf_shdrp;
  1798. bfd_boolean again;
  1799. _bfd_elf_gc_mark_extra_sections (info, gc_mark_hook);
  1800. /* Marking EH data may cause additional code sections to be marked,
  1801. requiring multiple passes. */
  1802. again = TRUE;
  1803. while (again)
  1804. {
  1805. again = FALSE;
  1806. for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
  1807. {
  1808. asection *o;
  1809. if (! is_tic6x_elf (sub))
  1810. continue;
  1811. elf_shdrp = elf_elfsections (sub);
  1812. for (o = sub->sections; o != NULL; o = o->next)
  1813. {
  1814. Elf_Internal_Shdr *hdr;
  1815. hdr = &elf_section_data (o)->this_hdr;
  1816. if (hdr->sh_type == SHT_C6000_UNWIND
  1817. && hdr->sh_link
  1818. && hdr->sh_link < elf_numsections (sub)
  1819. && !o->gc_mark
  1820. && elf_shdrp[hdr->sh_link]->bfd_section->gc_mark)
  1821. {
  1822. again = TRUE;
  1823. if (!_bfd_elf_gc_mark (info, o, gc_mark_hook))
  1824. return FALSE;
  1825. }
  1826. }
  1827. }
  1828. }
  1829. return TRUE;
  1830. }
  1831. /* Return TRUE if this is an unwinding table index. */
  1832. static bfd_boolean
  1833. is_tic6x_elf_unwind_section_name (const char *name)
  1834. {
  1835. return (CONST_STRNEQ (name, ELF_STRING_C6000_unwind)
  1836. || CONST_STRNEQ (name, ELF_STRING_C6000_unwind_once));
  1837. }
  1838. /* Set the type and flags for an unwinding index table. We do this by
  1839. the section name, which is a hack, but ought to work. */
  1840. static bfd_boolean
  1841. elf32_tic6x_fake_sections (bfd *abfd ATTRIBUTE_UNUSED,
  1842. Elf_Internal_Shdr *hdr, asection *sec)
  1843. {
  1844. const char * name;
  1845. name = bfd_get_section_name (abfd, sec);
  1846. if (is_tic6x_elf_unwind_section_name (name))
  1847. {
  1848. hdr->sh_type = SHT_C6000_UNWIND;
  1849. hdr->sh_flags |= SHF_LINK_ORDER;
  1850. }
  1851. return TRUE;
  1852. }
  1853. /* Update the got entry reference counts for the section being removed. */
  1854. static bfd_boolean
  1855. elf32_tic6x_gc_sweep_hook (bfd *abfd,
  1856. struct bfd_link_info *info,
  1857. asection *sec,
  1858. const Elf_Internal_Rela *relocs)
  1859. {
  1860. struct elf32_tic6x_link_hash_table *htab;
  1861. Elf_Internal_Shdr *symtab_hdr;
  1862. struct elf_link_hash_entry **sym_hashes;
  1863. bfd_signed_vma *local_got_refcounts;
  1864. const Elf_Internal_Rela *rel, *relend;
  1865. if (bfd_link_relocatable (info))
  1866. return TRUE;
  1867. htab = elf32_tic6x_hash_table (info);
  1868. if (htab == NULL)
  1869. return FALSE;
  1870. elf_section_data (sec)->local_dynrel = NULL;
  1871. symtab_hdr = &elf_symtab_hdr (abfd);
  1872. sym_hashes = elf_sym_hashes (abfd);
  1873. local_got_refcounts = elf_local_got_refcounts (abfd);
  1874. relend = relocs + sec->reloc_count;
  1875. for (rel = relocs; rel < relend; rel++)
  1876. {
  1877. unsigned long r_symndx;
  1878. unsigned int r_type;
  1879. struct elf_link_hash_entry *h = NULL;
  1880. r_symndx = ELF32_R_SYM (rel->r_info);
  1881. if (r_symndx >= symtab_hdr->sh_info)
  1882. {
  1883. struct elf32_tic6x_link_hash_entry *eh;
  1884. struct elf_dyn_relocs **pp;
  1885. struct elf_dyn_relocs *p;
  1886. h = sym_hashes[r_symndx - symtab_hdr->sh_info];
  1887. while (h->root.type == bfd_link_hash_indirect
  1888. || h->root.type == bfd_link_hash_warning)
  1889. h = (struct elf_link_hash_entry *) h->root.u.i.link;
  1890. eh = (struct elf32_tic6x_link_hash_entry *) h;
  1891. for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
  1892. if (p->sec == sec)
  1893. {
  1894. /* Everything must go for SEC. */
  1895. *pp = p->next;
  1896. break;
  1897. }
  1898. }
  1899. r_type = ELF32_R_TYPE (rel->r_info);
  1900. switch (r_type)
  1901. {
  1902. case R_C6000_SBR_GOT_U15_W:
  1903. case R_C6000_SBR_GOT_L16_W:
  1904. case R_C6000_SBR_GOT_H16_W:
  1905. case R_C6000_EHTYPE:
  1906. if (h != NULL)
  1907. {
  1908. if (h->got.refcount > 0)
  1909. h->got.refcount -= 1;
  1910. }
  1911. else if (local_got_refcounts != NULL)
  1912. {
  1913. if (local_got_refcounts[r_symndx] > 0)
  1914. local_got_refcounts[r_symndx] -= 1;
  1915. }
  1916. break;
  1917. default:
  1918. break;
  1919. }
  1920. }
  1921. return TRUE;
  1922. }
  1923. /* Adjust a symbol defined by a dynamic object and referenced by a
  1924. regular object. The current definition is in some section of the
  1925. dynamic object, but we're not including those sections. We have to
  1926. change the definition to something the rest of the link can
  1927. understand. */
  1928. static bfd_boolean
  1929. elf32_tic6x_adjust_dynamic_symbol (struct bfd_link_info *info,
  1930. struct elf_link_hash_entry *h)
  1931. {
  1932. struct elf32_tic6x_link_hash_table *htab;
  1933. bfd *dynobj;
  1934. asection *s;
  1935. dynobj = elf_hash_table (info)->dynobj;
  1936. /* Make sure we know what is going on here. */
  1937. BFD_ASSERT (dynobj != NULL
  1938. && (h->needs_plt
  1939. || h->u.weakdef != NULL
  1940. || (h->def_dynamic && h->ref_regular && !h->def_regular)));
  1941. /* If this is a function, put it in the procedure linkage table. We
  1942. will fill in the contents of the procedure linkage table later,
  1943. when we know the address of the .got section. */
  1944. if (h->type == STT_FUNC
  1945. || h->needs_plt)
  1946. {
  1947. if (h->plt.refcount <= 0
  1948. || SYMBOL_CALLS_LOCAL (info, h)
  1949. || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
  1950. && h->root.type == bfd_link_hash_undefweak))
  1951. {
  1952. /* This case can occur if we saw a PLT32 reloc in an input
  1953. file, but the symbol was never referred to by a dynamic
  1954. object, or if all references were garbage collected. In
  1955. such a case, we don't actually need to build a procedure
  1956. linkage table, and we can just do a PC32 reloc instead. */
  1957. h->plt.offset = (bfd_vma) -1;
  1958. h->needs_plt = 0;
  1959. }
  1960. return TRUE;
  1961. }
  1962. /* If this is a weak symbol, and there is a real definition, the
  1963. processor independent code will have arranged for us to see the
  1964. real definition first, and we can just use the same value. */
  1965. if (h->u.weakdef != NULL)
  1966. {
  1967. BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
  1968. || h->u.weakdef->root.type == bfd_link_hash_defweak);
  1969. h->root.u.def.section = h->u.weakdef->root.u.def.section;
  1970. h->root.u.def.value = h->u.weakdef->root.u.def.value;
  1971. h->non_got_ref = h->u.weakdef->non_got_ref;
  1972. return TRUE;
  1973. }
  1974. /* This is a reference to a symbol defined by a dynamic object which
  1975. is not a function. */
  1976. /* If we are creating a shared library, we must presume that the
  1977. only references to the symbol are via the global offset table.
  1978. For such cases we need not do anything here; the relocations will
  1979. be handled correctly by relocate_section. */
  1980. if (bfd_link_pic (info))
  1981. return TRUE;
  1982. /* If there are no references to this symbol that do not use the
  1983. GOT, we don't need to generate a copy reloc. */
  1984. if (!h->non_got_ref)
  1985. return TRUE;
  1986. /* If -z nocopyreloc was given, we won't generate them either. */
  1987. if (info->nocopyreloc)
  1988. {
  1989. h->non_got_ref = 0;
  1990. return TRUE;
  1991. }
  1992. htab = elf32_tic6x_hash_table (info);
  1993. if (htab == NULL)
  1994. return FALSE;
  1995. /* We must allocate the symbol in our .dynbss section, which will
  1996. become part of the .bss section of the executable. There will be
  1997. an entry for this symbol in the .dynsym section. The dynamic
  1998. object will contain position independent code, so all references
  1999. from the dynamic object to this symbol will go through the global
  2000. offset table. The dynamic linker will use the .dynsym entry to
  2001. determine the address it must put in the global offset table, so
  2002. both the dynamic object and the regular object will refer to the
  2003. same memory location for the variable. */
  2004. /* We must generate a R_C6000_COPY reloc to tell the dynamic linker to
  2005. copy the initial value out of the dynamic object and into the
  2006. runtime process image. */
  2007. if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
  2008. {
  2009. htab->srelbss->size += sizeof (Elf32_External_Rela);
  2010. h->needs_copy = 1;
  2011. }
  2012. s = htab->sdynbss;
  2013. return _bfd_elf_adjust_dynamic_copy (info, h, s);
  2014. }
  2015. static bfd_boolean
  2016. elf32_tic6x_new_section_hook (bfd *abfd, asection *sec)
  2017. {
  2018. bfd_boolean ret;
  2019. /* Allocate target specific section data. */
  2020. if (!sec->used_by_bfd)
  2021. {
  2022. _tic6x_elf_section_data *sdata;
  2023. bfd_size_type amt = sizeof (*sdata);
  2024. sdata = (_tic6x_elf_section_data *) bfd_zalloc (abfd, amt);
  2025. if (sdata == NULL)
  2026. return FALSE;
  2027. sec->used_by_bfd = sdata;
  2028. }
  2029. ret = _bfd_elf_new_section_hook (abfd, sec);
  2030. sec->use_rela_p = elf32_tic6x_tdata (abfd)->use_rela_p;
  2031. return ret;
  2032. }
  2033. /* Return true if relocation REL against section SEC is a REL rather
  2034. than RELA relocation. RELOCS is the first relocation in the
  2035. section and ABFD is the bfd that contains SEC. */
  2036. static bfd_boolean
  2037. elf32_tic6x_rel_relocation_p (bfd *abfd, asection *sec,
  2038. const Elf_Internal_Rela *relocs,
  2039. const Elf_Internal_Rela *rel)
  2040. {
  2041. Elf_Internal_Shdr *rel_hdr;
  2042. const struct elf_backend_data *bed;
  2043. /* To determine which flavor of relocation this is, we depend on the
  2044. fact that the INPUT_SECTION's REL_HDR is read before RELA_HDR. */
  2045. rel_hdr = elf_section_data (sec)->rel.hdr;
  2046. if (rel_hdr == NULL)
  2047. return FALSE;
  2048. bed = get_elf_backend_data (abfd);
  2049. return ((size_t) (rel - relocs)
  2050. < NUM_SHDR_ENTRIES (rel_hdr) * bed->s->int_rels_per_ext_rel);
  2051. }
  2052. /* We need dynamic symbols for every section, since segments can
  2053. relocate independently. */
  2054. static bfd_boolean
  2055. elf32_tic6x_link_omit_section_dynsym (bfd *output_bfd ATTRIBUTE_UNUSED,
  2056. struct bfd_link_info *info ATTRIBUTE_UNUSED,
  2057. asection *p)
  2058. {
  2059. switch (elf_section_data (p)->this_hdr.sh_type)
  2060. {
  2061. case SHT_PROGBITS:
  2062. case SHT_NOBITS:
  2063. /* If sh_type is yet undecided, assume it could be
  2064. SHT_PROGBITS/SHT_NOBITS. */
  2065. case SHT_NULL:
  2066. return FALSE;
  2067. /* There shouldn't be section relative relocations
  2068. against any other section. */
  2069. default:
  2070. return TRUE;
  2071. }
  2072. }
  2073. static bfd_boolean
  2074. elf32_tic6x_relocate_section (bfd *output_bfd,
  2075. struct bfd_link_info *info,
  2076. bfd *input_bfd,
  2077. asection *input_section,
  2078. bfd_byte *contents,
  2079. Elf_Internal_Rela *relocs,
  2080. Elf_Internal_Sym *local_syms,
  2081. asection **local_sections)
  2082. {
  2083. struct elf32_tic6x_link_hash_table *htab;
  2084. Elf_Internal_Shdr *symtab_hdr;
  2085. struct elf_link_hash_entry **sym_hashes;
  2086. bfd_vma *local_got_offsets;
  2087. Elf_Internal_Rela *rel;
  2088. Elf_Internal_Rela *relend;
  2089. bfd_boolean ok = TRUE;
  2090. htab = elf32_tic6x_hash_table (info);
  2091. symtab_hdr = & elf_symtab_hdr (input_bfd);
  2092. sym_hashes = elf_sym_hashes (input_bfd);
  2093. local_got_offsets = elf_local_got_offsets (input_bfd);
  2094. relend = relocs + input_section->reloc_count;
  2095. for (rel = relocs; rel < relend; rel ++)
  2096. {
  2097. int r_type;
  2098. unsigned long r_symndx;
  2099. arelent bfd_reloc;
  2100. reloc_howto_type *howto;
  2101. Elf_Internal_Sym *sym;
  2102. asection *sec;
  2103. struct elf_link_hash_entry *h;
  2104. bfd_vma off, off2, relocation;
  2105. bfd_boolean unresolved_reloc;
  2106. bfd_reloc_status_type r;
  2107. struct bfd_link_hash_entry *sbh;
  2108. bfd_boolean is_rel;
  2109. r_type = ELF32_R_TYPE (rel->r_info);
  2110. r_symndx = ELF32_R_SYM (rel->r_info);
  2111. is_rel = elf32_tic6x_rel_relocation_p (input_bfd, input_section,
  2112. relocs, rel);
  2113. if (is_rel)
  2114. elf32_tic6x_info_to_howto_rel (input_bfd, &bfd_reloc, rel);
  2115. else
  2116. elf32_tic6x_info_to_howto (input_bfd, &bfd_reloc, rel);
  2117. howto = bfd_reloc.howto;
  2118. if (howto == NULL)
  2119. {
  2120. bfd_set_error (bfd_error_bad_value);
  2121. return FALSE;
  2122. }
  2123. h = NULL;
  2124. sym = NULL;
  2125. sec = NULL;
  2126. unresolved_reloc = FALSE;
  2127. if (r_symndx < symtab_hdr->sh_info)
  2128. {
  2129. sym = local_syms + r_symndx;
  2130. sec = local_sections[r_symndx];
  2131. relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
  2132. }
  2133. else
  2134. {
  2135. bfd_boolean warned, ignored;
  2136. RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
  2137. r_symndx, symtab_hdr, sym_hashes,
  2138. h, sec, relocation,
  2139. unresolved_reloc, warned, ignored);
  2140. }
  2141. if (sec != NULL && discarded_section (sec))
  2142. RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
  2143. rel, 1, relend, howto, 0, contents);
  2144. if (bfd_link_relocatable (info))
  2145. {
  2146. if (is_rel
  2147. && sym != NULL
  2148. && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
  2149. {
  2150. rel->r_addend = 0;
  2151. relocation = sec->output_offset + sym->st_value;
  2152. r = _bfd_relocate_contents (howto, input_bfd, relocation,
  2153. contents + rel->r_offset);
  2154. goto done_reloc;
  2155. }
  2156. continue;
  2157. }
  2158. switch (r_type)
  2159. {
  2160. case R_C6000_NONE:
  2161. case R_C6000_ALIGN:
  2162. case R_C6000_FPHEAD:
  2163. case R_C6000_NOCMP:
  2164. /* No action needed. */
  2165. continue;
  2166. case R_C6000_PCR_S21:
  2167. /* A branch to an undefined weak symbol is turned into a
  2168. "b .s2 B3" instruction if the existing insn is of the
  2169. form "b .s2 symbol". */
  2170. if (h ? h->root.type == bfd_link_hash_undefweak
  2171. && (htab->elf.splt == NULL || h->plt.offset == (bfd_vma) -1)
  2172. : r_symndx != STN_UNDEF && bfd_is_und_section (sec))
  2173. {
  2174. unsigned long oldval;
  2175. oldval = bfd_get_32 (input_bfd, contents + rel->r_offset);
  2176. if ((oldval & 0x7e) == 0x12)
  2177. {
  2178. oldval &= 0xF0000001;
  2179. bfd_put_32 (input_bfd, oldval | 0x000c0362,
  2180. contents + rel->r_offset);
  2181. r = bfd_reloc_ok;
  2182. goto done_reloc;
  2183. }
  2184. }
  2185. case R_C6000_PCR_S12:
  2186. case R_C6000_PCR_S10:
  2187. case R_C6000_PCR_S7:
  2188. if (h != NULL
  2189. && h->plt.offset != (bfd_vma) -1
  2190. && htab->elf.splt != NULL)
  2191. {
  2192. relocation = (htab->elf.splt->output_section->vma
  2193. + htab->elf.splt->output_offset
  2194. + h->plt.offset);
  2195. }
  2196. /* Generic PC-relative handling produces a value relative to
  2197. the exact location of the relocation. Adjust it to be
  2198. relative to the start of the fetch packet instead. */
  2199. relocation += (input_section->output_section->vma
  2200. + input_section->output_offset
  2201. + rel->r_offset) & 0x1f;
  2202. unresolved_reloc = FALSE;
  2203. break;
  2204. case R_C6000_PCR_H16:
  2205. case R_C6000_PCR_L16:
  2206. off = (input_section->output_section->vma
  2207. + input_section->output_offset
  2208. + rel->r_offset);
  2209. /* These must be calculated as R = S - FP(FP(PC) - A).
  2210. PC, here, is the value we just computed in OFF. RELOCATION
  2211. has the address of S + A. */
  2212. relocation -= rel->r_addend;
  2213. off2 = ((off & ~(bfd_vma)0x1f) - rel->r_addend) & (bfd_vma)~0x1f;
  2214. off2 = relocation - off2;
  2215. relocation = off + off2;
  2216. break;
  2217. case R_C6000_DSBT_INDEX:
  2218. relocation = elf32_tic6x_hash_table (info)->params.dsbt_index;
  2219. if (!bfd_link_pic (info) || relocation != 0)
  2220. break;
  2221. /* fall through */
  2222. case R_C6000_ABS32:
  2223. case R_C6000_ABS16:
  2224. case R_C6000_ABS8:
  2225. case R_C6000_ABS_S16:
  2226. case R_C6000_ABS_L16:
  2227. case R_C6000_ABS_H16:
  2228. /* When generating a shared object or relocatable executable, these
  2229. relocations are copied into the output file to be resolved at
  2230. run time. */
  2231. if ((bfd_link_pic (info) || elf32_tic6x_using_dsbt (output_bfd))
  2232. && (input_section->flags & SEC_ALLOC)
  2233. && (h == NULL
  2234. || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
  2235. || h->root.type != bfd_link_hash_undefweak))
  2236. {
  2237. Elf_Internal_Rela outrel;
  2238. bfd_boolean skip, relocate;
  2239. asection *sreloc;
  2240. unresolved_reloc = FALSE;
  2241. sreloc = elf_section_data (input_section)->sreloc;
  2242. BFD_ASSERT (sreloc != NULL && sreloc->contents != NULL);
  2243. skip = FALSE;
  2244. relocate = FALSE;
  2245. outrel.r_offset =
  2246. _bfd_elf_section_offset (output_bfd, info, input_section,
  2247. rel->r_offset);
  2248. if (outrel.r_offset == (bfd_vma) -1)
  2249. skip = TRUE;
  2250. else if (outrel.r_offset == (bfd_vma) -2)
  2251. skip = TRUE, relocate = TRUE;
  2252. outrel.r_offset += (input_section->output_section->vma
  2253. + input_section->output_offset);
  2254. if (skip)
  2255. memset (&outrel, 0, sizeof outrel);
  2256. else if (h != NULL
  2257. && h->dynindx != -1
  2258. && (!bfd_link_pic (info)
  2259. || !SYMBOLIC_BIND (info, h)
  2260. || !h->def_regular))
  2261. {
  2262. outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
  2263. outrel.r_addend = rel->r_addend;
  2264. }
  2265. else
  2266. {
  2267. long indx;
  2268. outrel.r_addend = relocation + rel->r_addend;
  2269. if (bfd_is_abs_section (sec))
  2270. indx = 0;
  2271. else if (sec == NULL || sec->owner == NULL)
  2272. {
  2273. bfd_set_error (bfd_error_bad_value);
  2274. return FALSE;
  2275. }
  2276. else
  2277. {
  2278. asection *osec;
  2279. osec = sec->output_section;
  2280. indx = elf_section_data (osec)->dynindx;
  2281. outrel.r_addend -= osec->vma;
  2282. BFD_ASSERT (indx != 0);
  2283. }
  2284. outrel.r_info = ELF32_R_INFO (indx, r_type);
  2285. }
  2286. elf32_tic6x_install_rela (output_bfd, sreloc, &outrel);
  2287. /* If this reloc is against an external symbol, we do not want to
  2288. fiddle with the addend. Otherwise, we need to include the symbol
  2289. value so that it becomes an addend for the dynamic reloc. */
  2290. if (! relocate)
  2291. continue;
  2292. }
  2293. /* Generic logic OK. */
  2294. break;
  2295. case R_C6000_SBR_U15_B:
  2296. case R_C6000_SBR_U15_H:
  2297. case R_C6000_SBR_U15_W:
  2298. case R_C6000_SBR_S16:
  2299. case R_C6000_SBR_L16_B:
  2300. case R_C6000_SBR_L16_H:
  2301. case R_C6000_SBR_L16_W:
  2302. case R_C6000_SBR_H16_B:
  2303. case R_C6000_SBR_H16_H:
  2304. case R_C6000_SBR_H16_W:
  2305. sbh = bfd_link_hash_lookup (info->hash, "__c6xabi_DSBT_BASE",
  2306. FALSE, FALSE, TRUE);
  2307. if (sbh != NULL
  2308. && (sbh->type == bfd_link_hash_defined
  2309. || sbh->type == bfd_link_hash_defweak))
  2310. {
  2311. if (h ? (h->root.type == bfd_link_hash_undefweak
  2312. && (htab->elf.splt == NULL
  2313. || h->plt.offset == (bfd_vma) -1))
  2314. : r_symndx != STN_UNDEF && bfd_is_und_section (sec))
  2315. relocation = 0;
  2316. else
  2317. relocation -= (sbh->u.def.value
  2318. + sbh->u.def.section->output_section->vma
  2319. + sbh->u.def.section->output_offset);
  2320. }
  2321. else
  2322. {
  2323. (*_bfd_error_handler) (_("%B: SB-relative relocation but "
  2324. "__c6xabi_DSBT_BASE not defined"),
  2325. input_bfd);
  2326. ok = FALSE;
  2327. continue;
  2328. }
  2329. break;
  2330. case R_C6000_SBR_GOT_U15_W:
  2331. case R_C6000_SBR_GOT_L16_W:
  2332. case R_C6000_SBR_GOT_H16_W:
  2333. case R_C6000_EHTYPE:
  2334. /* Relocation is to the entry for this symbol in the global
  2335. offset table. */
  2336. if (htab->elf.sgot == NULL)
  2337. abort ();
  2338. if (h != NULL)
  2339. {
  2340. bfd_boolean dyn;
  2341. off = h->got.offset;
  2342. dyn = htab->elf.dynamic_sections_created;
  2343. if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
  2344. bfd_link_pic (info),
  2345. h)
  2346. || (bfd_link_pic (info)
  2347. && SYMBOL_REFERENCES_LOCAL (info, h))
  2348. || (ELF_ST_VISIBILITY (h->other)
  2349. && h->root.type == bfd_link_hash_undefweak))
  2350. {
  2351. /* This is actually a static link, or it is a
  2352. -Bsymbolic link and the symbol is defined
  2353. locally, or the symbol was forced to be local
  2354. because of a version file. We must initialize
  2355. this entry in the global offset table. Since the
  2356. offset must always be a multiple of 4, we use the
  2357. least significant bit to record whether we have
  2358. initialized it already.
  2359. When doing a dynamic link, we create a .rel.got
  2360. relocation entry to initialize the value. This
  2361. is done in the finish_dynamic_symbol routine. */
  2362. if ((off & 1) != 0)
  2363. off &= ~1;
  2364. else
  2365. {
  2366. bfd_put_32 (output_bfd, relocation,
  2367. htab->elf.sgot->contents + off);
  2368. h->got.offset |= 1;
  2369. if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
  2370. bfd_link_pic (info),
  2371. h)
  2372. && !(ELF_ST_VISIBILITY (h->other)
  2373. && h->root.type == bfd_link_hash_undefweak))
  2374. elf32_tic6x_make_got_dynreloc (output_bfd, htab, sec,
  2375. off);
  2376. }
  2377. }
  2378. else
  2379. unresolved_reloc = FALSE;
  2380. }
  2381. else
  2382. {
  2383. if (local_got_offsets == NULL)
  2384. abort ();
  2385. off = local_got_offsets[r_symndx];
  2386. /* The offset must always be a multiple of 4. We use
  2387. the least significant bit to record whether we have
  2388. already generated the necessary reloc. */
  2389. if ((off & 1) != 0)
  2390. off &= ~1;
  2391. else
  2392. {
  2393. bfd_put_32 (output_bfd, relocation,
  2394. htab->elf.sgot->contents + off);
  2395. if (bfd_link_pic (info) || elf32_tic6x_using_dsbt (output_bfd))
  2396. elf32_tic6x_make_got_dynreloc (output_bfd, htab, sec, off);
  2397. local_got_offsets[r_symndx] |= 1;
  2398. }
  2399. }
  2400. if (off >= (bfd_vma) -2)
  2401. abort ();
  2402. if (htab->dsbt)
  2403. relocation = (htab->elf.sgot->output_section->vma
  2404. + htab->elf.sgot->output_offset + off
  2405. - htab->dsbt->output_section->vma
  2406. - htab->dsbt->output_offset);
  2407. else
  2408. relocation = (htab->elf.sgot->output_section->vma
  2409. + htab->elf.sgot->output_offset + off
  2410. - htab->elf.sgotplt->output_section->vma
  2411. - htab->elf.sgotplt->output_offset);
  2412. if (rel->r_addend != 0)
  2413. {
  2414. /* We can't do anything for a relocation which is against
  2415. a symbol *plus offset*. GOT holds relocations for
  2416. symbols. Make this an error; the compiler isn't
  2417. allowed to pass us these kinds of things. */
  2418. if (h == NULL)
  2419. (*_bfd_error_handler)
  2420. (_("%B, section %A: relocation %s with non-zero addend %d"
  2421. " against local symbol"),
  2422. input_bfd,
  2423. input_section,
  2424. elf32_tic6x_howto_table[r_type].name,
  2425. rel->r_addend);
  2426. else
  2427. (*_bfd_error_handler)
  2428. (_("%B, section %A: relocation %s with non-zero addend %d"
  2429. " against symbol `%s'"),
  2430. input_bfd,
  2431. input_section,
  2432. elf32_tic6x_howto_table[r_type].name,
  2433. rel->r_addend,
  2434. h->root.root.string[0] != '\0' ? h->root.root.string
  2435. : _("[whose name is lost]"));
  2436. bfd_set_error (bfd_error_bad_value);
  2437. return FALSE;
  2438. }
  2439. break;
  2440. case R_C6000_PREL31:
  2441. if (h != NULL
  2442. && h->plt.offset != (bfd_vma) -1
  2443. && htab->elf.splt != NULL)
  2444. {
  2445. relocation = (htab->elf.splt->output_section->vma
  2446. + htab->elf.splt->output_offset
  2447. + h->plt.offset);
  2448. }
  2449. break;
  2450. case R_C6000_COPY:
  2451. /* Invalid in relocatable object. */
  2452. default:
  2453. /* Unknown relocation. */
  2454. (*_bfd_error_handler) (_("%B: invalid relocation type %d"),
  2455. input_bfd, r_type);
  2456. ok = FALSE;
  2457. continue;
  2458. }
  2459. r = _bfd_final_link_relocate (howto, input_bfd, input_section,
  2460. contents, rel->r_offset,
  2461. relocation, rel->r_addend);
  2462. done_reloc:
  2463. if (r == bfd_reloc_ok
  2464. && howto->complain_on_overflow == complain_overflow_bitfield)
  2465. {
  2466. /* Generic overflow handling accepts cases the ABI says
  2467. should be rejected for R_C6000_ABS16 and
  2468. R_C6000_ABS8. */
  2469. bfd_vma value = (relocation + rel->r_addend) & 0xffffffff;
  2470. bfd_vma sbit = 1 << (howto->bitsize - 1);
  2471. bfd_vma sbits = (-(bfd_vma) sbit) & 0xffffffff;
  2472. bfd_vma value_sbits = value & sbits;
  2473. if (value_sbits != 0
  2474. && value_sbits != sbit
  2475. && value_sbits != sbits)
  2476. r = bfd_reloc_overflow;
  2477. }
  2478. if (r != bfd_reloc_ok)
  2479. {
  2480. const char *name;
  2481. const char *error_message;
  2482. if (h != NULL)
  2483. name = h->root.root.string;
  2484. else
  2485. {
  2486. name = bfd_elf_string_from_elf_section (input_bfd,
  2487. symtab_hdr->sh_link,
  2488. sym->st_name);
  2489. if (name == NULL)
  2490. return FALSE;
  2491. if (*name == '\0')
  2492. name = bfd_section_name (input_bfd, sec);
  2493. }
  2494. switch (r)
  2495. {
  2496. case bfd_reloc_overflow:
  2497. /* If the overflowing reloc was to an undefined symbol,
  2498. we have already printed one error message and there
  2499. is no point complaining again. */
  2500. if ((! h ||
  2501. h->root.type != bfd_link_hash_undefined)
  2502. && (!((*info->callbacks->reloc_overflow)
  2503. (info, (h ? &h->root : NULL), name, howto->name,
  2504. (bfd_vma) 0, input_bfd, input_section,
  2505. rel->r_offset))))
  2506. return FALSE;
  2507. break;
  2508. case bfd_reloc_undefined:
  2509. if (!((*info->callbacks->undefined_symbol)
  2510. (info, name, input_bfd, input_section,
  2511. rel->r_offset, TRUE)))
  2512. return FALSE;
  2513. break;
  2514. case bfd_reloc_outofrange:
  2515. error_message = _("out of range");
  2516. goto common_error;
  2517. case bfd_reloc_notsupported:
  2518. error_message = _("unsupported relocation");
  2519. goto common_error;
  2520. case bfd_reloc_dangerous:
  2521. error_message = _("dangerous relocation");
  2522. goto common_error;
  2523. default:
  2524. error_message = _("unknown error");
  2525. /* Fall through. */
  2526. common_error:
  2527. BFD_ASSERT (error_message != NULL);
  2528. if (!((*info->callbacks->reloc_dangerous)
  2529. (info, error_message, input_bfd, input_section,
  2530. rel->r_offset)))
  2531. return FALSE;
  2532. break;
  2533. }
  2534. }
  2535. }
  2536. return ok;
  2537. }
  2538. /* Look through the relocs for a section during the first phase, and
  2539. calculate needed space in the global offset table, procedure linkage
  2540. table, and dynamic reloc sections. */
  2541. static bfd_boolean
  2542. elf32_tic6x_check_relocs (bfd *abfd, struct bfd_link_info *info,
  2543. asection *sec, const Elf_Internal_Rela *relocs)
  2544. {
  2545. struct elf32_tic6x_link_hash_table *htab;
  2546. Elf_Internal_Shdr *symtab_hdr;
  2547. struct elf_link_hash_entry **sym_hashes;
  2548. const Elf_Internal_Rela *rel;
  2549. const Elf_Internal_Rela *rel_end;
  2550. asection *sreloc;
  2551. if (bfd_link_relocatable (info))
  2552. return TRUE;
  2553. htab = elf32_tic6x_hash_table (info);
  2554. symtab_hdr = &elf_symtab_hdr (abfd);
  2555. sym_hashes = elf_sym_hashes (abfd);
  2556. /* Create dynamic sections for relocatable executables so that we can
  2557. copy relocations. */
  2558. if ((bfd_link_pic (info) || elf32_tic6x_using_dsbt (abfd))
  2559. && ! htab->elf.dynamic_sections_created)
  2560. {
  2561. if (! _bfd_elf_link_create_dynamic_sections (abfd, info))
  2562. return FALSE;
  2563. }
  2564. sreloc = NULL;
  2565. rel_end = relocs + sec->reloc_count;
  2566. for (rel = relocs; rel < rel_end; rel++)
  2567. {
  2568. unsigned int r_type;
  2569. unsigned long r_symndx;
  2570. struct elf_link_hash_entry *h;
  2571. Elf_Internal_Sym *isym;
  2572. r_symndx = ELF32_R_SYM (rel->r_info);
  2573. r_type = ELF32_R_TYPE (rel->r_info);
  2574. if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
  2575. {
  2576. (*_bfd_error_handler) (_("%B: bad symbol index: %d"),
  2577. abfd,
  2578. r_symndx);
  2579. return FALSE;
  2580. }
  2581. if (r_symndx < symtab_hdr->sh_info)
  2582. {
  2583. /* A local symbol. */
  2584. isym = bfd_sym_from_r_symndx (&htab->sym_cache,
  2585. abfd, r_symndx);
  2586. if (isym == NULL)
  2587. return FALSE;
  2588. h = NULL;
  2589. }
  2590. else
  2591. {
  2592. isym = NULL;
  2593. h = sym_hashes[r_symndx - symtab_hdr->sh_info];
  2594. while (h->root.type == bfd_link_hash_indirect
  2595. || h->root.type == bfd_link_hash_warning)
  2596. h = (struct elf_link_hash_entry *) h->root.u.i.link;
  2597. /* PR15323, ref flags aren't set for references in the same
  2598. object. */
  2599. h->root.non_ir_ref = 1;
  2600. }
  2601. switch (r_type)
  2602. {
  2603. case R_C6000_PCR_S21:
  2604. case R_C6000_PREL31:
  2605. /* This symbol requires a procedure linkage table entry. We
  2606. actually build the entry in adjust_dynamic_symbol,
  2607. because this might be a case of linking PIC code which is
  2608. never referenced by a dynamic object, in which case we
  2609. don't need to generate a procedure linkage table entry
  2610. after all. */
  2611. /* If this is a local symbol, we resolve it directly without
  2612. creating a procedure linkage table entry. */
  2613. if (h == NULL)
  2614. continue;
  2615. h->needs_plt = 1;
  2616. h->plt.refcount += 1;
  2617. break;
  2618. case R_C6000_SBR_GOT_U15_W:
  2619. case R_C6000_SBR_GOT_L16_W:
  2620. case R_C6000_SBR_GOT_H16_W:
  2621. case R_C6000_EHTYPE:
  2622. /* This symbol requires a global offset table entry. */
  2623. if (h != NULL)
  2624. {
  2625. h->got.refcount += 1;
  2626. }
  2627. else
  2628. {
  2629. bfd_signed_vma *local_got_refcounts;
  2630. /* This is a global offset table entry for a local symbol. */
  2631. local_got_refcounts = elf_local_got_refcounts (abfd);
  2632. if (local_got_refcounts == NULL)
  2633. {
  2634. bfd_size_type size;
  2635. size = symtab_hdr->sh_info;
  2636. size *= (sizeof (bfd_signed_vma)
  2637. + sizeof (bfd_vma) + sizeof(char));
  2638. local_got_refcounts = bfd_zalloc (abfd, size);
  2639. if (local_got_refcounts == NULL)
  2640. return FALSE;
  2641. elf_local_got_refcounts (abfd) = local_got_refcounts;
  2642. }
  2643. local_got_refcounts[r_symndx] += 1;
  2644. }
  2645. if (htab->elf.sgot == NULL)
  2646. {
  2647. if (htab->elf.dynobj == NULL)
  2648. htab->elf.dynobj = abfd;
  2649. if (!_bfd_elf_create_got_section (htab->elf.dynobj, info))
  2650. return FALSE;
  2651. }
  2652. break;
  2653. case R_C6000_DSBT_INDEX:
  2654. /* We'd like to check for nonzero dsbt_index here, but it's
  2655. set up only after check_relocs is called. Instead, we
  2656. store the number of R_C6000_DSBT_INDEX relocs in the
  2657. pc_count field, and potentially discard the extra space
  2658. in elf32_tic6x_allocate_dynrelocs. */
  2659. if (!bfd_link_pic (info))
  2660. break;
  2661. /* fall through */
  2662. case R_C6000_ABS32:
  2663. case R_C6000_ABS16:
  2664. case R_C6000_ABS8:
  2665. case R_C6000_ABS_S16:
  2666. case R_C6000_ABS_L16:
  2667. case R_C6000_ABS_H16:
  2668. /* If we are creating a shared library, and this is a reloc
  2669. against a global symbol, or a non PC relative reloc
  2670. against a local symbol, then we need to copy the reloc
  2671. into the shared library. However, if we are linking with
  2672. -Bsymbolic, we do not need to copy a reloc against a
  2673. global symbol which is defined in an object we are
  2674. including in the link (i.e., DEF_REGULAR is set). At
  2675. this point we have not seen all the input files, so it is
  2676. possible that DEF_REGULAR is not set now but will be set
  2677. later (it is never cleared). In case of a weak definition,
  2678. DEF_REGULAR may be cleared later by a strong definition in
  2679. a shared library. We account for that possibility below by
  2680. storing information in the relocs_copied field of the hash
  2681. table entry. A similar situation occurs when creating
  2682. shared libraries and symbol visibility changes render the
  2683. symbol local.
  2684. If on the other hand, we are creating an executable, we
  2685. may need to keep relocations for symbols satisfied by a
  2686. dynamic library if we manage to avoid copy relocs for the
  2687. symbol. */
  2688. if ((bfd_link_pic (info) || elf32_tic6x_using_dsbt (abfd))
  2689. && (sec->flags & SEC_ALLOC) != 0)
  2690. {
  2691. struct elf_dyn_relocs *p;
  2692. struct elf_dyn_relocs **head;
  2693. /* We must copy these reloc types into the output file.
  2694. Create a reloc section in dynobj and make room for
  2695. this reloc. */
  2696. if (sreloc == NULL)
  2697. {
  2698. if (htab->elf.dynobj == NULL)
  2699. htab->elf.dynobj = abfd;
  2700. sreloc = _bfd_elf_make_dynamic_reloc_section
  2701. (sec, htab->elf.dynobj, 2, abfd, /*rela? */ TRUE);
  2702. if (sreloc == NULL)
  2703. return FALSE;
  2704. }
  2705. /* If this is a global symbol, we count the number of
  2706. relocations we need for this symbol. */
  2707. if (h != NULL)
  2708. {
  2709. head = &((struct elf32_tic6x_link_hash_entry *) h)->dyn_relocs;
  2710. }
  2711. else
  2712. {
  2713. /* Track dynamic relocs needed for local syms too.
  2714. We really need local syms available to do this
  2715. easily. Oh well. */
  2716. void **vpp;
  2717. asection *s;
  2718. s = bfd_section_from_elf_index (abfd, isym->st_shndx);
  2719. if (s == NULL)
  2720. s = sec;
  2721. vpp = &elf_section_data (s)->local_dynrel;
  2722. head = (struct elf_dyn_relocs **)vpp;
  2723. }
  2724. p = *head;
  2725. if (p == NULL || p->sec != sec)
  2726. {
  2727. bfd_size_type amt = sizeof *p;
  2728. p = bfd_alloc (htab->elf.dynobj, amt);
  2729. if (p == NULL)
  2730. return FALSE;
  2731. p->next = *head;
  2732. *head = p;
  2733. p->sec = sec;
  2734. p->count = 0;
  2735. p->pc_count = 0;
  2736. }
  2737. p->count += 1;
  2738. if (r_type == R_C6000_DSBT_INDEX)
  2739. p->pc_count += 1;
  2740. }
  2741. break;
  2742. case R_C6000_SBR_U15_B:
  2743. case R_C6000_SBR_U15_H:
  2744. case R_C6000_SBR_U15_W:
  2745. case R_C6000_SBR_S16:
  2746. case R_C6000_SBR_L16_B:
  2747. case R_C6000_SBR_L16_H:
  2748. case R_C6000_SBR_L16_W:
  2749. case R_C6000_SBR_H16_B:
  2750. case R_C6000_SBR_H16_H:
  2751. case R_C6000_SBR_H16_W:
  2752. if (h != NULL && bfd_link_executable (info))
  2753. {
  2754. /* For B14-relative addresses, we might need a copy
  2755. reloc. */
  2756. h->non_got_ref = 1;
  2757. }
  2758. break;
  2759. default:
  2760. break;
  2761. }
  2762. }
  2763. return TRUE;
  2764. }
  2765. static bfd_boolean
  2766. elf32_tic6x_add_symbol_hook (bfd *abfd,
  2767. struct bfd_link_info *info ATTRIBUTE_UNUSED,
  2768. Elf_Internal_Sym *sym,
  2769. const char **namep ATTRIBUTE_UNUSED,
  2770. flagword *flagsp ATTRIBUTE_UNUSED,
  2771. asection **secp,
  2772. bfd_vma *valp)
  2773. {
  2774. switch (sym->st_shndx)
  2775. {
  2776. case SHN_TIC6X_SCOMMON:
  2777. *secp = bfd_make_section_old_way (abfd, ".scommon");
  2778. (*secp)->flags |= SEC_IS_COMMON;
  2779. *valp = sym->st_size;
  2780. (void) bfd_set_section_alignment (abfd, *secp, bfd_log2 (sym->st_value));
  2781. break;
  2782. }
  2783. return TRUE;
  2784. }
  2785. static void
  2786. elf32_tic6x_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, asymbol *asym)
  2787. {
  2788. elf_symbol_type *elfsym;
  2789. elfsym = (elf_symbol_type *) asym;
  2790. switch (elfsym->internal_elf_sym.st_shndx)
  2791. {
  2792. case SHN_TIC6X_SCOMMON:
  2793. if (tic6x_elf_scom_section.name == NULL)
  2794. {
  2795. /* Initialize the small common section. */
  2796. tic6x_elf_scom_section.name = ".scommon";
  2797. tic6x_elf_scom_section.flags = SEC_IS_COMMON;
  2798. tic6x_elf_scom_section.output_section = &tic6x_elf_scom_section;
  2799. tic6x_elf_scom_section.symbol = &tic6x_elf_scom_symbol;
  2800. tic6x_elf_scom_section.symbol_ptr_ptr = &tic6x_elf_scom_symbol_ptr;
  2801. tic6x_elf_scom_symbol.name = ".scommon";
  2802. tic6x_elf_scom_symbol.flags = BSF_SECTION_SYM;
  2803. tic6x_elf_scom_symbol.section = &tic6x_elf_scom_section;
  2804. tic6x_elf_scom_symbol_ptr = &tic6x_elf_scom_symbol;
  2805. }
  2806. asym->section = &tic6x_elf_scom_section;
  2807. asym->value = elfsym->internal_elf_sym.st_size;
  2808. break;
  2809. }
  2810. }
  2811. static int
  2812. elf32_tic6x_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
  2813. const char *name ATTRIBUTE_UNUSED,
  2814. Elf_Internal_Sym *sym,
  2815. asection *input_sec,
  2816. struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
  2817. {
  2818. /* If we see a common symbol, which implies a relocatable link, then
  2819. if a symbol was small common in an input file, mark it as small
  2820. common in the output file. */
  2821. if (sym->st_shndx == SHN_COMMON && strcmp (input_sec->name, ".scommon") == 0)
  2822. sym->st_shndx = SHN_TIC6X_SCOMMON;
  2823. return 1;
  2824. }
  2825. static bfd_boolean
  2826. elf32_tic6x_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED,
  2827. asection *sec,
  2828. int *retval)
  2829. {
  2830. if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
  2831. {
  2832. *retval = SHN_TIC6X_SCOMMON;
  2833. return TRUE;
  2834. }
  2835. return FALSE;
  2836. }
  2837. /* Allocate space in .plt, .got and associated reloc sections for
  2838. dynamic relocs. */
  2839. static bfd_boolean
  2840. elf32_tic6x_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
  2841. {
  2842. struct bfd_link_info *info;
  2843. struct elf32_tic6x_link_hash_table *htab;
  2844. struct elf32_tic6x_link_hash_entry *eh;
  2845. struct elf_dyn_relocs *p;
  2846. if (h->root.type == bfd_link_hash_indirect)
  2847. return TRUE;
  2848. eh = (struct elf32_tic6x_link_hash_entry *) h;
  2849. info = (struct bfd_link_info *) inf;
  2850. htab = elf32_tic6x_hash_table (info);
  2851. if (htab->elf.dynamic_sections_created && h->plt.refcount > 0)
  2852. {
  2853. /* Make sure this symbol is output as a dynamic symbol.
  2854. Undefined weak syms won't yet be marked as dynamic. */
  2855. if (h->dynindx == -1 && !h->forced_local)
  2856. {
  2857. if (! bfd_elf_link_record_dynamic_symbol (info, h))
  2858. return FALSE;
  2859. }
  2860. if (bfd_link_pic (info)
  2861. || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))
  2862. {
  2863. asection *s = htab->elf.splt;
  2864. /* If this is the first .plt entry, make room for the special
  2865. first entry. */
  2866. if (s->size == 0)
  2867. s->size += PLT_ENTRY_SIZE;
  2868. h->plt.offset = s->size;
  2869. /* If this symbol is not defined in a regular file, and we are
  2870. not generating a shared library, then set the symbol to this
  2871. location in the .plt. This is required to make function
  2872. pointers compare as equal between the normal executable and
  2873. the shared library. */
  2874. if (! bfd_link_pic (info) && !h->def_regular)
  2875. {
  2876. h->root.u.def.section = s;
  2877. h->root.u.def.value = h->plt.offset;
  2878. }
  2879. /* Make room for this entry. */
  2880. s->size += PLT_ENTRY_SIZE;
  2881. /* We also need to make an entry in the .got.plt section, which
  2882. will be placed in the .got section by the linker script. */
  2883. htab->elf.sgotplt->size += 4;
  2884. /* We also need to make an entry in the .rel.plt section. */
  2885. htab->elf.srelplt->size += sizeof (Elf32_External_Rela);
  2886. }
  2887. else
  2888. {
  2889. h->plt.offset = (bfd_vma) -1;
  2890. h->needs_plt = 0;
  2891. }
  2892. }
  2893. else
  2894. {
  2895. h->plt.offset = (bfd_vma) -1;
  2896. h->needs_plt = 0;
  2897. }
  2898. if (h->got.refcount > 0)
  2899. {
  2900. asection *s;
  2901. /* Make sure this symbol is output as a dynamic symbol.
  2902. Undefined weak syms won't yet be marked as dynamic. */
  2903. if (h->dynindx == -1
  2904. && !h->forced_local)
  2905. {
  2906. if (! bfd_elf_link_record_dynamic_symbol (info, h))
  2907. return FALSE;
  2908. }
  2909. s = htab->elf.sgot;
  2910. h->got.offset = s->size;
  2911. s->size += 4;
  2912. if (!(ELF_ST_VISIBILITY (h->other)
  2913. && h->root.type == bfd_link_hash_undefweak))
  2914. htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
  2915. }
  2916. else
  2917. h->got.offset = (bfd_vma) -1;
  2918. if (eh->dyn_relocs == NULL)
  2919. return TRUE;
  2920. /* Discard relocs on undefined weak syms with non-default
  2921. visibility. */
  2922. if (bfd_link_pic (info) || elf32_tic6x_using_dsbt (htab->obfd))
  2923. {
  2924. /* We use the pc_count field to hold the number of
  2925. R_C6000_DSBT_INDEX relocs. */
  2926. if (htab->params.dsbt_index != 0)
  2927. {
  2928. struct elf_dyn_relocs **pp;
  2929. for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
  2930. {
  2931. p->count -= p->pc_count;
  2932. p->pc_count = 0;
  2933. if (p->count == 0)
  2934. *pp = p->next;
  2935. else
  2936. pp = &p->next;
  2937. }
  2938. }
  2939. if (eh->dyn_relocs != NULL
  2940. && h->root.type == bfd_link_hash_undefweak)
  2941. {
  2942. if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
  2943. eh->dyn_relocs = NULL;
  2944. /* Make sure undefined weak symbols are output as a dynamic
  2945. symbol in PIEs. */
  2946. else if (h->dynindx == -1
  2947. && !h->forced_local)
  2948. {
  2949. if (! bfd_elf_link_record_dynamic_symbol (info, h))
  2950. return FALSE;
  2951. }
  2952. }
  2953. }
  2954. /* Finally, allocate space. */
  2955. for (p = eh->dyn_relocs; p != NULL; p = p->next)
  2956. {
  2957. asection *sreloc;
  2958. sreloc = elf_section_data (p->sec)->sreloc;
  2959. BFD_ASSERT (sreloc != NULL);
  2960. sreloc->size += p->count * sizeof (Elf32_External_Rela);
  2961. }
  2962. return TRUE;
  2963. }
  2964. /* Find any dynamic relocs that apply to read-only sections. */
  2965. static bfd_boolean
  2966. elf32_tic6x_readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf)
  2967. {
  2968. struct elf32_tic6x_link_hash_entry *eh;
  2969. struct elf_dyn_relocs *p;
  2970. eh = (struct elf32_tic6x_link_hash_entry *) h;
  2971. for (p = eh->dyn_relocs; p != NULL; p = p->next)
  2972. {
  2973. asection *s = p->sec->output_section;
  2974. if (s != NULL && (s->flags & SEC_READONLY) != 0)
  2975. {
  2976. struct bfd_link_info *info = (struct bfd_link_info *) inf;
  2977. info->flags |= DF_TEXTREL;
  2978. /* Not an error, just cut short the traversal. */
  2979. return FALSE;
  2980. }
  2981. }
  2982. return TRUE;
  2983. }
  2984. /* Set the sizes of the dynamic sections. */
  2985. static bfd_boolean
  2986. elf32_tic6x_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
  2987. {
  2988. struct elf32_tic6x_link_hash_table *htab;
  2989. bfd *dynobj;
  2990. asection *s;
  2991. bfd_boolean relocs;
  2992. bfd *ibfd;
  2993. htab = elf32_tic6x_hash_table (info);
  2994. dynobj = htab->elf.dynobj;
  2995. if (dynobj == NULL)
  2996. abort ();
  2997. if (htab->elf.dynamic_sections_created)
  2998. {
  2999. /* Set the contents of the .interp section to the interpreter. */
  3000. if (bfd_link_executable (info) && !info->nointerp)
  3001. {
  3002. s = bfd_get_linker_section (dynobj, ".interp");
  3003. if (s == NULL)
  3004. abort ();
  3005. s->size = sizeof ELF_DYNAMIC_INTERPRETER;
  3006. s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
  3007. }
  3008. }
  3009. /* Set up .got offsets for local syms, and space for local dynamic
  3010. relocs. */
  3011. for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
  3012. {
  3013. bfd_signed_vma *local_got;
  3014. bfd_signed_vma *end_local_got;
  3015. bfd_size_type locsymcount;
  3016. Elf_Internal_Shdr *symtab_hdr;
  3017. asection *srel;
  3018. for (s = ibfd->sections; s != NULL; s = s->next)
  3019. {
  3020. struct elf_dyn_relocs *p;
  3021. for (p = ((struct elf_dyn_relocs *)
  3022. elf_section_data (s)->local_dynrel);
  3023. p != NULL;
  3024. p = p->next)
  3025. {
  3026. if (!bfd_is_abs_section (p->sec)
  3027. && bfd_is_abs_section (p->sec->output_section))
  3028. {
  3029. /* Input section has been discarded, either because
  3030. it is a copy of a linkonce section or due to
  3031. linker script /DISCARD/, so we'll be discarding
  3032. the relocs too. */
  3033. }
  3034. else if (p->count != 0)
  3035. {
  3036. srel = elf_section_data (p->sec)->sreloc;
  3037. srel->size += p->count * sizeof (Elf32_External_Rela);
  3038. if ((p->sec->output_section->flags & SEC_READONLY) != 0)
  3039. info->flags |= DF_TEXTREL;
  3040. }
  3041. }
  3042. }
  3043. local_got = elf_local_got_refcounts (ibfd);
  3044. if (!local_got)
  3045. continue;
  3046. symtab_hdr = &elf_symtab_hdr (ibfd);
  3047. locsymcount = symtab_hdr->sh_info;
  3048. end_local_got = local_got + locsymcount;
  3049. s = htab->elf.sgot;
  3050. srel = htab->elf.srelgot;
  3051. for (; local_got < end_local_got; ++local_got)
  3052. {
  3053. if (*local_got > 0)
  3054. {
  3055. *local_got = s->size;
  3056. s->size += 4;
  3057. if (bfd_link_pic (info) || elf32_tic6x_using_dsbt (output_bfd))
  3058. {
  3059. srel->size += sizeof (Elf32_External_Rela);
  3060. }
  3061. }
  3062. else
  3063. *local_got = (bfd_vma) -1;
  3064. }
  3065. }
  3066. /* Allocate global sym .plt and .got entries, and space for global
  3067. sym dynamic relocs. */
  3068. elf_link_hash_traverse (&htab->elf, elf32_tic6x_allocate_dynrelocs, info);
  3069. /* We now have determined the sizes of the various dynamic sections.
  3070. Allocate memory for them. */
  3071. relocs = FALSE;
  3072. for (s = dynobj->sections; s != NULL; s = s->next)
  3073. {
  3074. bfd_boolean strip_section = TRUE;
  3075. if ((s->flags & SEC_LINKER_CREATED) == 0)
  3076. continue;
  3077. if (s == htab->dsbt)
  3078. s->size = 4 * htab->params.dsbt_size;
  3079. else if (s == htab->elf.splt
  3080. || s == htab->elf.sgot
  3081. || s == htab->elf.sgotplt
  3082. || s == htab->sdynbss)
  3083. {
  3084. /* Strip this section if we don't need it; see the
  3085. comment below. */
  3086. /* We'd like to strip these sections if they aren't needed, but if
  3087. we've exported dynamic symbols from them we must leave them.
  3088. It's too late to tell BFD to get rid of the symbols. */
  3089. if (htab->elf.hplt != NULL)
  3090. strip_section = FALSE;
  3091. /* Round up the size of the PLT section to a multiple of 32. */
  3092. if (s == htab->elf.splt && s->size > 0)
  3093. s->size = (s->size + 31) & ~(bfd_vma)31;
  3094. }
  3095. else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
  3096. {
  3097. if (s->size != 0
  3098. && s != htab->elf.srelplt)
  3099. relocs = TRUE;
  3100. /* We use the reloc_count field as a counter if we need
  3101. to copy relocs into the output file. */
  3102. s->reloc_count = 0;
  3103. }
  3104. else
  3105. {
  3106. /* It's not one of our sections, so don't allocate space. */
  3107. continue;
  3108. }
  3109. if (s->size == 0)
  3110. {
  3111. /* If we don't need this section, strip it from the
  3112. output file. This is mostly to handle .rel.bss and
  3113. .rel.plt. We must create both sections in
  3114. create_dynamic_sections, because they must be created
  3115. before the linker maps input sections to output
  3116. sections. The linker does that before
  3117. adjust_dynamic_symbol is called, and it is that
  3118. function which decides whether anything needs to go
  3119. into these sections. */
  3120. if (strip_section)
  3121. s->flags |= SEC_EXCLUDE;
  3122. continue;
  3123. }
  3124. if ((s->flags & SEC_HAS_CONTENTS) == 0)
  3125. continue;
  3126. /* Allocate memory for the section contents. We use bfd_zalloc
  3127. here in case unused entries are not reclaimed before the
  3128. section's contents are written out. This should not happen,
  3129. but this way if it does, we get a R_C6000_NONE reloc instead
  3130. of garbage. */
  3131. s->contents = bfd_zalloc (dynobj, s->size);
  3132. if (s->contents == NULL)
  3133. return FALSE;
  3134. }
  3135. if (htab->elf.dynamic_sections_created)
  3136. {
  3137. /* Add some entries to the .dynamic section. We fill in the
  3138. values later, in elf32_tic6x_finish_dynamic_sections, but we
  3139. must add the entries now so that we get the correct size for
  3140. the .dynamic section. The DT_DEBUG entry is filled in by the
  3141. dynamic linker and used by the debugger. */
  3142. #define add_dynamic_entry(TAG, VAL) \
  3143. _bfd_elf_add_dynamic_entry (info, TAG, VAL)
  3144. if (bfd_link_executable (info))
  3145. {
  3146. if (!add_dynamic_entry (DT_DEBUG, 0))
  3147. return FALSE;
  3148. }
  3149. if (!add_dynamic_entry (DT_C6000_DSBT_BASE, 0)
  3150. || !add_dynamic_entry (DT_C6000_DSBT_SIZE, htab->params.dsbt_size)
  3151. || !add_dynamic_entry (DT_C6000_DSBT_INDEX,
  3152. htab->params.dsbt_index))
  3153. return FALSE;
  3154. if (htab->elf.splt->size != 0)
  3155. {
  3156. if (!add_dynamic_entry (DT_PLTGOT, 0)
  3157. || !add_dynamic_entry (DT_PLTRELSZ, 0)
  3158. || !add_dynamic_entry (DT_PLTREL, DT_RELA)
  3159. || !add_dynamic_entry (DT_JMPREL, 0))
  3160. return FALSE;
  3161. }
  3162. if (relocs)
  3163. {
  3164. if (!add_dynamic_entry (DT_RELA, 0)
  3165. || !add_dynamic_entry (DT_RELASZ, 0)
  3166. || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
  3167. return FALSE;
  3168. /* If any dynamic relocs apply to a read-only section,
  3169. then we need a DT_TEXTREL entry. */
  3170. if ((info->flags & DF_TEXTREL) == 0)
  3171. elf_link_hash_traverse (&htab->elf,
  3172. elf32_tic6x_readonly_dynrelocs, info);
  3173. if ((info->flags & DF_TEXTREL) != 0)
  3174. {
  3175. if (!add_dynamic_entry (DT_TEXTREL, 0))
  3176. return FALSE;
  3177. }
  3178. }
  3179. }
  3180. #undef add_dynamic_entry
  3181. return TRUE;
  3182. }
  3183. /* This function is called after all the input files have been read,
  3184. and the input sections have been assigned to output sections. */
  3185. static bfd_boolean
  3186. elf32_tic6x_always_size_sections (bfd *output_bfd, struct bfd_link_info *info)
  3187. {
  3188. if (elf32_tic6x_using_dsbt (output_bfd) && !bfd_link_relocatable (info)
  3189. && !bfd_elf_stack_segment_size (output_bfd, info,
  3190. "__stacksize", DEFAULT_STACK_SIZE))
  3191. return FALSE;
  3192. return TRUE;
  3193. }
  3194. static bfd_boolean
  3195. elf32_tic6x_finish_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
  3196. struct bfd_link_info *info)
  3197. {
  3198. struct elf32_tic6x_link_hash_table *htab;
  3199. bfd *dynobj;
  3200. asection *sdyn;
  3201. htab = elf32_tic6x_hash_table (info);
  3202. dynobj = htab->elf.dynobj;
  3203. sdyn = bfd_get_linker_section (dynobj, ".dynamic");
  3204. if (elf_hash_table (info)->dynamic_sections_created)
  3205. {
  3206. Elf32_External_Dyn * dyncon;
  3207. Elf32_External_Dyn * dynconend;
  3208. BFD_ASSERT (sdyn != NULL);
  3209. dyncon = (Elf32_External_Dyn *) sdyn->contents;
  3210. dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
  3211. for (; dyncon < dynconend; dyncon++)
  3212. {
  3213. Elf_Internal_Dyn dyn;
  3214. asection *s;
  3215. bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
  3216. switch (dyn.d_tag)
  3217. {
  3218. default:
  3219. break;
  3220. case DT_C6000_DSBT_BASE:
  3221. s = htab->dsbt;
  3222. dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset);
  3223. break;
  3224. case DT_PLTGOT:
  3225. s = htab->elf.sgotplt;
  3226. dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
  3227. break;
  3228. case DT_JMPREL:
  3229. s = htab->elf.srelplt;
  3230. dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
  3231. break;
  3232. case DT_PLTRELSZ:
  3233. s = htab->elf.srelplt;
  3234. dyn.d_un.d_val = s->size;
  3235. break;
  3236. }
  3237. bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
  3238. }
  3239. /* Fill in the first entry in the procedure linkage table. */
  3240. if (htab->elf.splt && htab->elf.splt->size > 0)
  3241. {
  3242. bfd_vma got_offs = (htab->elf.sgotplt->output_section->vma
  3243. + htab->elf.sgotplt->output_offset
  3244. - htab->dsbt->output_section->vma
  3245. - htab->dsbt->output_offset) / 4;
  3246. /* ldw .D2T2 *+b14[$GOT(0)],b2 */
  3247. bfd_put_32 (output_bfd, got_offs << 8 | 0x0100006e,
  3248. htab->elf.splt->contents);
  3249. /* ldw .D2T2 *+b14[$GOT(4)],b1 */
  3250. bfd_put_32 (output_bfd, (got_offs + 1) << 8 | 0x0080006e,
  3251. htab->elf.splt->contents + 4);
  3252. /* nop 3 */
  3253. bfd_put_32 (output_bfd, 0x00004000,
  3254. htab->elf.splt->contents + 8);
  3255. /* b .s2 b2 */
  3256. bfd_put_32 (output_bfd, 0x00080362,
  3257. htab->elf.splt->contents + 12);
  3258. /* nop 5 */
  3259. bfd_put_32 (output_bfd, 0x00008000,
  3260. htab->elf.splt->contents + 16);
  3261. elf_section_data (htab->elf.splt->output_section)
  3262. ->this_hdr.sh_entsize = PLT_ENTRY_SIZE;
  3263. }
  3264. }
  3265. return TRUE;
  3266. }
  3267. /* Return address for Ith PLT stub in section PLT, for relocation REL
  3268. or (bfd_vma) -1 if it should not be included. */
  3269. static bfd_vma
  3270. elf32_tic6x_plt_sym_val (bfd_vma i, const asection *plt,
  3271. const arelent *rel ATTRIBUTE_UNUSED)
  3272. {
  3273. return plt->vma + (i + 1) * PLT_ENTRY_SIZE;
  3274. }
  3275. static int
  3276. elf32_tic6x_obj_attrs_arg_type (int tag)
  3277. {
  3278. if (tag == Tag_ABI_compatibility)
  3279. return ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_STR_VAL;
  3280. else if (tag & 1)
  3281. return ATTR_TYPE_FLAG_STR_VAL;
  3282. else
  3283. return ATTR_TYPE_FLAG_INT_VAL;
  3284. }
  3285. static int
  3286. elf32_tic6x_obj_attrs_order (int num)
  3287. {
  3288. if (num == LEAST_KNOWN_OBJ_ATTRIBUTE)
  3289. return Tag_ABI_conformance;
  3290. if ((num - 1) < Tag_ABI_conformance)
  3291. return num - 1;
  3292. return num;
  3293. }
  3294. static bfd_boolean
  3295. elf32_tic6x_obj_attrs_handle_unknown (bfd *abfd, int tag)
  3296. {
  3297. if ((tag & 127) < 64)
  3298. {
  3299. _bfd_error_handler
  3300. (_("%B: error: unknown mandatory EABI object attribute %d"),
  3301. abfd, tag);
  3302. bfd_set_error (bfd_error_bad_value);
  3303. return FALSE;
  3304. }
  3305. else
  3306. {
  3307. _bfd_error_handler
  3308. (_("%B: warning: unknown EABI object attribute %d"),
  3309. abfd, tag);
  3310. return TRUE;
  3311. }
  3312. }
  3313. /* Merge the Tag_ISA attribute values ARCH1 and ARCH2
  3314. and return the merged value. At present, all merges succeed, so no
  3315. return value for errors is defined. */
  3316. int
  3317. elf32_tic6x_merge_arch_attributes (int arch1, int arch2)
  3318. {
  3319. int min_arch, max_arch;
  3320. min_arch = (arch1 < arch2 ? arch1 : arch2);
  3321. max_arch = (arch1 > arch2 ? arch1 : arch2);
  3322. /* In most cases, the numerically greatest value is the correct
  3323. merged value, but merging C64 and C67 results in C674X. */
  3324. if ((min_arch == C6XABI_Tag_ISA_C67X
  3325. || min_arch == C6XABI_Tag_ISA_C67XP)
  3326. && (max_arch == C6XABI_Tag_ISA_C64X
  3327. || max_arch == C6XABI_Tag_ISA_C64XP))
  3328. return C6XABI_Tag_ISA_C674X;
  3329. return max_arch;
  3330. }
  3331. /* Convert a Tag_ABI_array_object_alignment or
  3332. Tag_ABI_array_object_align_expected tag value TAG to a
  3333. corresponding alignment value; return the alignment, or -1 for an
  3334. unknown tag value. */
  3335. static int
  3336. elf32_tic6x_tag_to_array_alignment (int tag)
  3337. {
  3338. switch (tag)
  3339. {
  3340. case 0:
  3341. return 8;
  3342. case 1:
  3343. return 4;
  3344. case 2:
  3345. return 16;
  3346. default:
  3347. return -1;
  3348. }
  3349. }
  3350. /* Convert a Tag_ABI_array_object_alignment or
  3351. Tag_ABI_array_object_align_expected alignment ALIGN to a
  3352. corresponding tag value; return the tag value. */
  3353. static int
  3354. elf32_tic6x_array_alignment_to_tag (int align)
  3355. {
  3356. switch (align)
  3357. {
  3358. case 8:
  3359. return 0;
  3360. case 4:
  3361. return 1;
  3362. case 16:
  3363. return 2;
  3364. default:
  3365. abort ();
  3366. }
  3367. }
  3368. /* Merge attributes from IBFD and OBFD, returning TRUE if the merge
  3369. succeeded, FALSE otherwise. */
  3370. static bfd_boolean
  3371. elf32_tic6x_merge_attributes (bfd *ibfd, bfd *obfd)
  3372. {
  3373. bfd_boolean result = TRUE;
  3374. obj_attribute *in_attr;
  3375. obj_attribute *out_attr;
  3376. int i;
  3377. int array_align_in, array_align_out, array_expect_in, array_expect_out;
  3378. if (!elf_known_obj_attributes_proc (obfd)[0].i)
  3379. {
  3380. /* This is the first object. Copy the attributes. */
  3381. _bfd_elf_copy_obj_attributes (ibfd, obfd);
  3382. out_attr = elf_known_obj_attributes_proc (obfd);
  3383. /* Use the Tag_null value to indicate the attributes have been
  3384. initialized. */
  3385. out_attr[0].i = 1;
  3386. return TRUE;
  3387. }
  3388. in_attr = elf_known_obj_attributes_proc (ibfd);
  3389. out_attr = elf_known_obj_attributes_proc (obfd);
  3390. /* No specification yet for handling of unknown attributes, so just
  3391. ignore them and handle known ones. */
  3392. if (out_attr[Tag_ABI_stack_align_preserved].i
  3393. < in_attr[Tag_ABI_stack_align_needed].i)
  3394. {
  3395. _bfd_error_handler
  3396. (_("error: %B requires more stack alignment than %B preserves"),
  3397. ibfd, obfd);
  3398. result = FALSE;
  3399. }
  3400. if (in_attr[Tag_ABI_stack_align_preserved].i
  3401. < out_attr[Tag_ABI_stack_align_needed].i)
  3402. {
  3403. _bfd_error_handler
  3404. (_("error: %B requires more stack alignment than %B preserves"),
  3405. obfd, ibfd);
  3406. result = FALSE;
  3407. }
  3408. array_align_in = elf32_tic6x_tag_to_array_alignment
  3409. (in_attr[Tag_ABI_array_object_alignment].i);
  3410. if (array_align_in == -1)
  3411. {
  3412. _bfd_error_handler
  3413. (_("error: unknown Tag_ABI_array_object_alignment value in %B"),
  3414. ibfd);
  3415. result = FALSE;
  3416. }
  3417. array_align_out = elf32_tic6x_tag_to_array_alignment
  3418. (out_attr[Tag_ABI_array_object_alignment].i);
  3419. if (array_align_out == -1)
  3420. {
  3421. _bfd_error_handler
  3422. (_("error: unknown Tag_ABI_array_object_alignment value in %B"),
  3423. obfd);
  3424. result = FALSE;
  3425. }
  3426. array_expect_in = elf32_tic6x_tag_to_array_alignment
  3427. (in_attr[Tag_ABI_array_object_align_expected].i);
  3428. if (array_expect_in == -1)
  3429. {
  3430. _bfd_error_handler
  3431. (_("error: unknown Tag_ABI_array_object_align_expected value in %B"),
  3432. ibfd);
  3433. result = FALSE;
  3434. }
  3435. array_expect_out = elf32_tic6x_tag_to_array_alignment
  3436. (out_attr[Tag_ABI_array_object_align_expected].i);
  3437. if (array_expect_out == -1)
  3438. {
  3439. _bfd_error_handler
  3440. (_("error: unknown Tag_ABI_array_object_align_expected value in %B"),
  3441. obfd);
  3442. result = FALSE;
  3443. }
  3444. if (array_align_out < array_expect_in)
  3445. {
  3446. _bfd_error_handler
  3447. (_("error: %B requires more array alignment than %B preserves"),
  3448. ibfd, obfd);
  3449. result = FALSE;
  3450. }
  3451. if (array_align_in < array_expect_out)
  3452. {
  3453. _bfd_error_handler
  3454. (_("error: %B requires more array alignment than %B preserves"),
  3455. obfd, ibfd);
  3456. result = FALSE;
  3457. }
  3458. for (i = LEAST_KNOWN_OBJ_ATTRIBUTE; i < NUM_KNOWN_OBJ_ATTRIBUTES; i++)
  3459. {
  3460. switch (i)
  3461. {
  3462. case Tag_ISA:
  3463. out_attr[i].i = elf32_tic6x_merge_arch_attributes (in_attr[i].i,
  3464. out_attr[i].i);
  3465. break;
  3466. case Tag_ABI_wchar_t:
  3467. if (out_attr[i].i == 0)
  3468. out_attr[i].i = in_attr[i].i;
  3469. if (out_attr[i].i != 0
  3470. && in_attr[i].i != 0
  3471. && out_attr[i].i != in_attr[i].i)
  3472. {
  3473. _bfd_error_handler
  3474. (_("warning: %B and %B differ in wchar_t size"), obfd, ibfd);
  3475. }
  3476. break;
  3477. case Tag_ABI_stack_align_needed:
  3478. if (out_attr[i].i < in_attr[i].i)
  3479. out_attr[i].i = in_attr[i].i;
  3480. break;
  3481. case Tag_ABI_stack_align_preserved:
  3482. if (out_attr[i].i > in_attr[i].i)
  3483. out_attr[i].i = in_attr[i].i;
  3484. break;
  3485. case Tag_ABI_DSBT:
  3486. if (out_attr[i].i != in_attr[i].i)
  3487. {
  3488. _bfd_error_handler
  3489. (_("warning: %B and %B differ in whether code is "
  3490. "compiled for DSBT"),
  3491. obfd, ibfd);
  3492. }
  3493. break;
  3494. case Tag_ABI_PIC:
  3495. case Tag_ABI_PID:
  3496. if (out_attr[i].i > in_attr[i].i)
  3497. out_attr[i].i = in_attr[i].i;
  3498. break;
  3499. case Tag_ABI_array_object_alignment:
  3500. if (array_align_out != -1
  3501. && array_align_in != -1
  3502. && array_align_out > array_align_in)
  3503. out_attr[i].i
  3504. = elf32_tic6x_array_alignment_to_tag (array_align_in);
  3505. break;
  3506. case Tag_ABI_array_object_align_expected:
  3507. if (array_expect_out != -1
  3508. && array_expect_in != -1
  3509. && array_expect_out < array_expect_in)
  3510. out_attr[i].i
  3511. = elf32_tic6x_array_alignment_to_tag (array_expect_in);
  3512. break;
  3513. case Tag_ABI_conformance:
  3514. /* Merging for this attribute is not specified. As on ARM,
  3515. treat a missing attribute as no claim to conform and only
  3516. merge identical values. */
  3517. if (out_attr[i].s == NULL
  3518. || in_attr[i].s == NULL
  3519. || strcmp (out_attr[i].s,
  3520. in_attr[i].s) != 0)
  3521. out_attr[i].s = NULL;
  3522. break;
  3523. case Tag_ABI_compatibility:
  3524. /* Merged in _bfd_elf_merge_object_attributes. */
  3525. break;
  3526. default:
  3527. result
  3528. = result && _bfd_elf_merge_unknown_attribute_low (ibfd, obfd, i);
  3529. break;
  3530. }
  3531. if (in_attr[i].type && !out_attr[i].type)
  3532. out_attr[i].type = in_attr[i].type;
  3533. }
  3534. /* Merge Tag_ABI_compatibility attributes and any common GNU ones. */
  3535. if (!_bfd_elf_merge_object_attributes (ibfd, obfd))
  3536. return FALSE;
  3537. result &= _bfd_elf_merge_unknown_attribute_list (ibfd, obfd);
  3538. return result;
  3539. }
  3540. static bfd_boolean
  3541. elf32_tic6x_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
  3542. {
  3543. if (!_bfd_generic_verify_endian_match (ibfd, obfd))
  3544. return FALSE;
  3545. if (! is_tic6x_elf (ibfd) || ! is_tic6x_elf (obfd))
  3546. return TRUE;
  3547. if (!elf32_tic6x_merge_attributes (ibfd, obfd))
  3548. return FALSE;
  3549. return TRUE;
  3550. }
  3551. /* Add a new unwind edit to the list described by HEAD, TAIL. If TINDEX is zero,
  3552. adds the edit to the start of the list. (The list must be built in order of
  3553. ascending TINDEX: the function's callers are primarily responsible for
  3554. maintaining that condition). */
  3555. static void
  3556. elf32_tic6x_add_unwind_table_edit (tic6x_unwind_table_edit **head,
  3557. tic6x_unwind_table_edit **tail,
  3558. tic6x_unwind_edit_type type,
  3559. asection *linked_section,
  3560. unsigned int tindex)
  3561. {
  3562. tic6x_unwind_table_edit *new_edit = (tic6x_unwind_table_edit *)
  3563. xmalloc (sizeof (tic6x_unwind_table_edit));
  3564. new_edit->type = type;
  3565. new_edit->linked_section = linked_section;
  3566. new_edit->index = tindex;
  3567. if (tindex > 0)
  3568. {
  3569. new_edit->next = NULL;
  3570. if (*tail)
  3571. (*tail)->next = new_edit;
  3572. (*tail) = new_edit;
  3573. if (!*head)
  3574. (*head) = new_edit;
  3575. }
  3576. else
  3577. {
  3578. new_edit->next = *head;
  3579. if (!*tail)
  3580. *tail = new_edit;
  3581. *head = new_edit;
  3582. }
  3583. }
  3584. static _tic6x_elf_section_data *
  3585. get_tic6x_elf_section_data (asection * sec)
  3586. {
  3587. if (sec && sec->owner && is_tic6x_elf (sec->owner))
  3588. return elf32_tic6x_section_data (sec);
  3589. else
  3590. return NULL;
  3591. }
  3592. /* Increase the size of EXIDX_SEC by ADJUST bytes. ADJUST must be negative. */
  3593. static void
  3594. elf32_tic6x_adjust_exidx_size (asection *exidx_sec, int adjust)
  3595. {
  3596. asection *out_sec;
  3597. if (!exidx_sec->rawsize)
  3598. exidx_sec->rawsize = exidx_sec->size;
  3599. bfd_set_section_size (exidx_sec->owner, exidx_sec, exidx_sec->size + adjust);
  3600. out_sec = exidx_sec->output_section;
  3601. /* Adjust size of output section. */
  3602. bfd_set_section_size (out_sec->owner, out_sec, out_sec->size +adjust);
  3603. }
  3604. /* Insert an EXIDX_CANTUNWIND marker at the end of a section. */
  3605. static void
  3606. elf32_tic6x_insert_cantunwind_after (asection *text_sec, asection *exidx_sec)
  3607. {
  3608. struct _tic6x_elf_section_data *exidx_data;
  3609. exidx_data = get_tic6x_elf_section_data (exidx_sec);
  3610. elf32_tic6x_add_unwind_table_edit (
  3611. &exidx_data->u.exidx.unwind_edit_list,
  3612. &exidx_data->u.exidx.unwind_edit_tail,
  3613. INSERT_EXIDX_CANTUNWIND_AT_END, text_sec, UINT_MAX);
  3614. elf32_tic6x_adjust_exidx_size (exidx_sec, 8);
  3615. }
  3616. /* Scan .cx6abi.exidx tables, and create a list describing edits which
  3617. should be made to those tables, such that:
  3618. 1. Regions without unwind data are marked with EXIDX_CANTUNWIND entries.
  3619. 2. Duplicate entries are merged together (EXIDX_CANTUNWIND, or unwind
  3620. codes which have been inlined into the index).
  3621. If MERGE_EXIDX_ENTRIES is false, duplicate entries are not merged.
  3622. The edits are applied when the tables are written
  3623. (in elf32_tic6x_write_section).
  3624. */
  3625. bfd_boolean
  3626. elf32_tic6x_fix_exidx_coverage (asection **text_section_order,
  3627. unsigned int num_text_sections,
  3628. struct bfd_link_info *info,
  3629. bfd_boolean merge_exidx_entries)
  3630. {
  3631. bfd *inp;
  3632. unsigned int last_second_word = 0, i;
  3633. asection *last_exidx_sec = NULL;
  3634. asection *last_text_sec = NULL;
  3635. int last_unwind_type = -1;
  3636. /* Walk over all EXIDX sections, and create backlinks from the corrsponding
  3637. text sections. */
  3638. for (inp = info->input_bfds; inp != NULL; inp = inp->link.next)
  3639. {
  3640. asection *sec;
  3641. for (sec = inp->sections; sec != NULL; sec = sec->next)
  3642. {
  3643. struct bfd_elf_section_data *elf_sec = elf_section_data (sec);
  3644. Elf_Internal_Shdr *hdr = &elf_sec->this_hdr;
  3645. if (!hdr || hdr->sh_type != SHT_C6000_UNWIND)
  3646. continue;
  3647. if (elf_sec->linked_to)
  3648. {
  3649. Elf_Internal_Shdr *linked_hdr
  3650. = &elf_section_data (elf_sec->linked_to)->this_hdr;
  3651. struct _tic6x_elf_section_data *linked_sec_tic6x_data
  3652. = get_tic6x_elf_section_data (linked_hdr->bfd_section);
  3653. if (linked_sec_tic6x_data == NULL)
  3654. continue;
  3655. /* Link this .c6xabi.exidx section back from the
  3656. text section it describes. */
  3657. linked_sec_tic6x_data->u.text.tic6x_exidx_sec = sec;
  3658. }
  3659. }
  3660. }
  3661. /* Walk all text sections in order of increasing VMA. Eilminate duplicate
  3662. index table entries (EXIDX_CANTUNWIND and inlined unwind opcodes),
  3663. and add EXIDX_CANTUNWIND entries for sections with no unwind table data. */
  3664. for (i = 0; i < num_text_sections; i++)
  3665. {
  3666. asection *sec = text_section_order[i];
  3667. asection *exidx_sec;
  3668. struct _tic6x_elf_section_data *tic6x_data
  3669. = get_tic6x_elf_section_data (sec);
  3670. struct _tic6x_elf_section_data *exidx_data;
  3671. bfd_byte *contents = NULL;
  3672. int deleted_exidx_bytes = 0;
  3673. bfd_vma j;
  3674. tic6x_unwind_table_edit *unwind_edit_head = NULL;
  3675. tic6x_unwind_table_edit *unwind_edit_tail = NULL;
  3676. Elf_Internal_Shdr *hdr;
  3677. bfd *ibfd;
  3678. if (tic6x_data == NULL)
  3679. continue;
  3680. exidx_sec = tic6x_data->u.text.tic6x_exidx_sec;
  3681. if (exidx_sec == NULL)
  3682. {
  3683. /* Section has no unwind data. */
  3684. if (last_unwind_type == 0 || !last_exidx_sec)
  3685. continue;
  3686. /* Ignore zero sized sections. */
  3687. if (sec->size == 0)
  3688. continue;
  3689. elf32_tic6x_insert_cantunwind_after (last_text_sec, last_exidx_sec);
  3690. last_unwind_type = 0;
  3691. continue;
  3692. }
  3693. /* Skip /DISCARD/ sections. */
  3694. if (bfd_is_abs_section (exidx_sec->output_section))
  3695. continue;
  3696. hdr = &elf_section_data (exidx_sec)->this_hdr;
  3697. if (hdr->sh_type != SHT_C6000_UNWIND)
  3698. continue;
  3699. exidx_data = get_tic6x_elf_section_data (exidx_sec);
  3700. if (exidx_data == NULL)
  3701. continue;
  3702. ibfd = exidx_sec->owner;
  3703. if (hdr->contents != NULL)
  3704. contents = hdr->contents;
  3705. else if (! bfd_malloc_and_get_section (ibfd, exidx_sec, &contents))
  3706. /* An error? */
  3707. continue;
  3708. for (j = 0; j < hdr->sh_size; j += 8)
  3709. {
  3710. unsigned int second_word = bfd_get_32 (ibfd, contents + j + 4);
  3711. int unwind_type;
  3712. int elide = 0;
  3713. /* An EXIDX_CANTUNWIND entry. */
  3714. if (second_word == 1)
  3715. {
  3716. if (last_unwind_type == 0)
  3717. elide = 1;
  3718. unwind_type = 0;
  3719. }
  3720. /* Inlined unwinding data. Merge if equal to previous. */
  3721. else if ((second_word & 0x80000000) != 0)
  3722. {
  3723. if (merge_exidx_entries
  3724. && last_second_word == second_word
  3725. && last_unwind_type == 1)
  3726. elide = 1;
  3727. unwind_type = 1;
  3728. last_second_word = second_word;
  3729. }
  3730. /* Normal table entry. In theory we could merge these too,
  3731. but duplicate entries are likely to be much less common. */
  3732. else
  3733. unwind_type = 2;
  3734. if (elide)
  3735. {
  3736. elf32_tic6x_add_unwind_table_edit (&unwind_edit_head,
  3737. &unwind_edit_tail, DELETE_EXIDX_ENTRY, NULL, j / 8);
  3738. deleted_exidx_bytes += 8;
  3739. }
  3740. last_unwind_type = unwind_type;
  3741. }
  3742. /* Free contents if we allocated it ourselves. */
  3743. if (contents != hdr->contents)
  3744. free (contents);
  3745. /* Record edits to be applied later (in elf32_tic6x_write_section). */
  3746. exidx_data->u.exidx.unwind_edit_list = unwind_edit_head;
  3747. exidx_data->u.exidx.unwind_edit_tail = unwind_edit_tail;
  3748. if (deleted_exidx_bytes > 0)
  3749. elf32_tic6x_adjust_exidx_size (exidx_sec, -deleted_exidx_bytes);
  3750. last_exidx_sec = exidx_sec;
  3751. last_text_sec = sec;
  3752. }
  3753. /* Add terminating CANTUNWIND entry. */
  3754. if (last_exidx_sec && last_unwind_type != 0)
  3755. elf32_tic6x_insert_cantunwind_after (last_text_sec, last_exidx_sec);
  3756. return TRUE;
  3757. }
  3758. /* Add ADDEND to lower 31 bits of VAL, leaving other bits unmodified. */
  3759. static unsigned long
  3760. elf32_tic6x_add_low31 (unsigned long val, bfd_vma addend)
  3761. {
  3762. return (val & ~0x7ffffffful) | ((val + addend) & 0x7ffffffful);
  3763. }
  3764. /* Copy an .c6xabi.exidx table entry, adding OFFSET to (applied) PREL31
  3765. relocations. OFFSET is in bytes, and will be scaled before encoding. */
  3766. static void
  3767. elf32_tic6x_copy_exidx_entry (bfd *output_bfd, bfd_byte *to, bfd_byte *from,
  3768. bfd_vma offset)
  3769. {
  3770. unsigned long first_word = bfd_get_32 (output_bfd, from);
  3771. unsigned long second_word = bfd_get_32 (output_bfd, from + 4);
  3772. offset >>= 1;
  3773. /* High bit of first word is supposed to be zero. */
  3774. if ((first_word & 0x80000000ul) == 0)
  3775. first_word = elf32_tic6x_add_low31 (first_word, offset);
  3776. /* If the high bit of the first word is clear, and the bit pattern is not 0x1
  3777. (EXIDX_CANTUNWIND), this is an offset to an .c6xabi.extab entry. */
  3778. if ((second_word != 0x1) && ((second_word & 0x80000000ul) == 0))
  3779. second_word = elf32_tic6x_add_low31 (second_word, offset);
  3780. bfd_put_32 (output_bfd, first_word, to);
  3781. bfd_put_32 (output_bfd, second_word, to + 4);
  3782. }
  3783. /* Do the actual mangling of exception index tables. */
  3784. static bfd_boolean
  3785. elf32_tic6x_write_section (bfd *output_bfd,
  3786. struct bfd_link_info *link_info,
  3787. asection *sec,
  3788. bfd_byte *contents)
  3789. {
  3790. _tic6x_elf_section_data *tic6x_data;
  3791. struct elf32_tic6x_link_hash_table *globals
  3792. = elf32_tic6x_hash_table (link_info);
  3793. bfd_vma offset = sec->output_section->vma + sec->output_offset;
  3794. if (globals == NULL)
  3795. return FALSE;
  3796. /* If this section has not been allocated an _tic6x_elf_section_data
  3797. structure then we cannot record anything. */
  3798. tic6x_data = get_tic6x_elf_section_data (sec);
  3799. if (tic6x_data == NULL)
  3800. return FALSE;
  3801. if (tic6x_data->elf.this_hdr.sh_type != SHT_C6000_UNWIND)
  3802. return FALSE;
  3803. tic6x_unwind_table_edit *edit_node
  3804. = tic6x_data->u.exidx.unwind_edit_list;
  3805. /* Now, sec->size is the size of the section we will write. The original
  3806. size (before we merged duplicate entries and inserted EXIDX_CANTUNWIND
  3807. markers) was sec->rawsize. (This isn't the case if we perform no
  3808. edits, then rawsize will be zero and we should use size). */
  3809. bfd_byte *edited_contents = (bfd_byte *) bfd_malloc (sec->size);
  3810. unsigned int input_size = sec->rawsize ? sec->rawsize : sec->size;
  3811. unsigned int in_index, out_index;
  3812. bfd_vma add_to_offsets = 0;
  3813. for (in_index = 0, out_index = 0; in_index * 8 < input_size || edit_node;)
  3814. {
  3815. if (edit_node)
  3816. {
  3817. unsigned int edit_index = edit_node->index;
  3818. if (in_index < edit_index && in_index * 8 < input_size)
  3819. {
  3820. elf32_tic6x_copy_exidx_entry (output_bfd,
  3821. edited_contents + out_index * 8,
  3822. contents + in_index * 8, add_to_offsets);
  3823. out_index++;
  3824. in_index++;
  3825. }
  3826. else if (in_index == edit_index
  3827. || (in_index * 8 >= input_size
  3828. && edit_index == UINT_MAX))
  3829. {
  3830. switch (edit_node->type)
  3831. {
  3832. case DELETE_EXIDX_ENTRY:
  3833. in_index++;
  3834. add_to_offsets += 8;
  3835. break;
  3836. case INSERT_EXIDX_CANTUNWIND_AT_END:
  3837. {
  3838. asection *text_sec = edit_node->linked_section;
  3839. bfd_vma text_offset = text_sec->output_section->vma
  3840. + text_sec->output_offset
  3841. + text_sec->size;
  3842. bfd_vma exidx_offset = offset + out_index * 8;
  3843. unsigned long prel31_offset;
  3844. /* Note: this is meant to be equivalent to an
  3845. R_C6000_PREL31 relocation. These synthetic
  3846. EXIDX_CANTUNWIND markers are not relocated by the
  3847. usual BFD method. */
  3848. prel31_offset = ((text_offset - exidx_offset) >> 1)
  3849. & 0x7ffffffful;
  3850. /* First address we can't unwind. */
  3851. bfd_put_32 (output_bfd, prel31_offset,
  3852. &edited_contents[out_index * 8]);
  3853. /* Code for EXIDX_CANTUNWIND. */
  3854. bfd_put_32 (output_bfd, 0x1,
  3855. &edited_contents[out_index * 8 + 4]);
  3856. out_index++;
  3857. add_to_offsets -= 8;
  3858. }
  3859. break;
  3860. }
  3861. edit_node = edit_node->next;
  3862. }
  3863. }
  3864. else
  3865. {
  3866. /* No more edits, copy remaining entries verbatim. */
  3867. elf32_tic6x_copy_exidx_entry (output_bfd,
  3868. edited_contents + out_index * 8,
  3869. contents + in_index * 8, add_to_offsets);
  3870. out_index++;
  3871. in_index++;
  3872. }
  3873. }
  3874. if (!(sec->flags & SEC_EXCLUDE) && !(sec->flags & SEC_NEVER_LOAD))
  3875. bfd_set_section_contents (output_bfd, sec->output_section,
  3876. edited_contents,
  3877. (file_ptr) sec->output_offset, sec->size);
  3878. return TRUE;
  3879. }
  3880. #define TARGET_LITTLE_SYM tic6x_elf32_le_vec
  3881. #define TARGET_LITTLE_NAME "elf32-tic6x-le"
  3882. #define TARGET_BIG_SYM tic6x_elf32_be_vec
  3883. #define TARGET_BIG_NAME "elf32-tic6x-be"
  3884. #define ELF_ARCH bfd_arch_tic6x
  3885. #define ELF_TARGET_ID TIC6X_ELF_DATA
  3886. #define ELF_MACHINE_CODE EM_TI_C6000
  3887. #define ELF_MAXPAGESIZE 0x1000
  3888. #define bfd_elf32_bfd_reloc_type_lookup elf32_tic6x_reloc_type_lookup
  3889. #define bfd_elf32_bfd_reloc_name_lookup elf32_tic6x_reloc_name_lookup
  3890. #define bfd_elf32_bfd_merge_private_bfd_data elf32_tic6x_merge_private_bfd_data
  3891. #define bfd_elf32_mkobject elf32_tic6x_mkobject
  3892. #define bfd_elf32_bfd_link_hash_table_create elf32_tic6x_link_hash_table_create
  3893. #define bfd_elf32_new_section_hook elf32_tic6x_new_section_hook
  3894. #define elf_backend_stack_align 8
  3895. #define elf_backend_can_gc_sections 1
  3896. #define elf_backend_default_use_rela_p 1
  3897. #define elf_backend_may_use_rel_p 1
  3898. #define elf_backend_may_use_rela_p 1
  3899. #define elf_backend_obj_attrs_arg_type elf32_tic6x_obj_attrs_arg_type
  3900. #define elf_backend_obj_attrs_handle_unknown elf32_tic6x_obj_attrs_handle_unknown
  3901. #define elf_backend_obj_attrs_order elf32_tic6x_obj_attrs_order
  3902. #define elf_backend_obj_attrs_section ".c6xabi.attributes"
  3903. #define elf_backend_obj_attrs_section_type SHT_C6000_ATTRIBUTES
  3904. #define elf_backend_obj_attrs_vendor "c6xabi"
  3905. #define elf_backend_can_refcount 1
  3906. #define elf_backend_want_got_plt 1
  3907. #define elf_backend_want_dynbss 1
  3908. #define elf_backend_plt_readonly 1
  3909. #define elf_backend_rela_normal 1
  3910. #define elf_backend_got_header_size 8
  3911. #define elf_backend_fake_sections elf32_tic6x_fake_sections
  3912. #define elf_backend_gc_sweep_hook elf32_tic6x_gc_sweep_hook
  3913. #define elf_backend_gc_mark_extra_sections elf32_tic6x_gc_mark_extra_sections
  3914. #define elf_backend_create_dynamic_sections \
  3915. elf32_tic6x_create_dynamic_sections
  3916. #define elf_backend_adjust_dynamic_symbol \
  3917. elf32_tic6x_adjust_dynamic_symbol
  3918. #define elf_backend_check_relocs elf32_tic6x_check_relocs
  3919. #define elf_backend_add_symbol_hook elf32_tic6x_add_symbol_hook
  3920. #define elf_backend_symbol_processing elf32_tic6x_symbol_processing
  3921. #define elf_backend_link_output_symbol_hook \
  3922. elf32_tic6x_link_output_symbol_hook
  3923. #define elf_backend_section_from_bfd_section \
  3924. elf32_tic6x_section_from_bfd_section
  3925. #define elf_backend_relocate_section elf32_tic6x_relocate_section
  3926. #define elf_backend_relocs_compatible _bfd_elf_relocs_compatible
  3927. #define elf_backend_finish_dynamic_symbol \
  3928. elf32_tic6x_finish_dynamic_symbol
  3929. #define elf_backend_always_size_sections \
  3930. elf32_tic6x_always_size_sections
  3931. #define elf_backend_size_dynamic_sections \
  3932. elf32_tic6x_size_dynamic_sections
  3933. #define elf_backend_finish_dynamic_sections \
  3934. elf32_tic6x_finish_dynamic_sections
  3935. #define bfd_elf32_bfd_final_link \
  3936. elf32_tic6x_final_link
  3937. #define elf_backend_write_section elf32_tic6x_write_section
  3938. #define elf_info_to_howto elf32_tic6x_info_to_howto
  3939. #define elf_info_to_howto_rel elf32_tic6x_info_to_howto_rel
  3940. #undef elf_backend_omit_section_dynsym
  3941. #define elf_backend_omit_section_dynsym elf32_tic6x_link_omit_section_dynsym
  3942. #define elf_backend_plt_sym_val elf32_tic6x_plt_sym_val
  3943. #include "elf32-target.h"
  3944. #undef elf32_bed
  3945. #define elf32_bed elf32_tic6x_linux_bed
  3946. #undef TARGET_LITTLE_SYM
  3947. #define TARGET_LITTLE_SYM tic6x_elf32_linux_le_vec
  3948. #undef TARGET_LITTLE_NAME
  3949. #define TARGET_LITTLE_NAME "elf32-tic6x-linux-le"
  3950. #undef TARGET_BIG_SYM
  3951. #define TARGET_BIG_SYM tic6x_elf32_linux_be_vec
  3952. #undef TARGET_BIG_NAME
  3953. #define TARGET_BIG_NAME "elf32-tic6x-linux-be"
  3954. #undef ELF_OSABI
  3955. #define ELF_OSABI ELFOSABI_C6000_LINUX
  3956. #include "elf32-target.h"
  3957. #undef elf32_bed
  3958. #define elf32_bed elf32_tic6x_elf_bed
  3959. #undef TARGET_LITTLE_SYM
  3960. #define TARGET_LITTLE_SYM tic6x_elf32_c6000_le_vec
  3961. #undef TARGET_LITTLE_NAME
  3962. #define TARGET_LITTLE_NAME "elf32-tic6x-elf-le"
  3963. #undef TARGET_BIG_SYM
  3964. #define TARGET_BIG_SYM tic6x_elf32_c6000_be_vec
  3965. #undef TARGET_BIG_NAME
  3966. #define TARGET_BIG_NAME "elf32-tic6x-elf-be"
  3967. #undef ELF_OSABI
  3968. #define ELF_OSABI ELFOSABI_C6000_ELFABI
  3969. #include "elf32-target.h"