elf-bfd.h 114 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167
  1. /* BFD back-end data structures for ELF files.
  2. Copyright (C) 1992-2022 Free Software Foundation, Inc.
  3. Written by Cygnus Support.
  4. This file is part of BFD, the Binary File Descriptor library.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA. */
  17. #ifndef _LIBELF_H_
  18. #define _LIBELF_H_ 1
  19. #include <stdlib.h>
  20. #include "elf/common.h"
  21. #include "elf/external.h"
  22. #include "elf/internal.h"
  23. #include "bfdlink.h"
  24. #ifndef ENABLE_CHECKING
  25. #define ENABLE_CHECKING 0
  26. #endif
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* The number of entries in a section is its size divided by the size
  31. of a single entry. This is normally only applicable to reloc and
  32. symbol table sections.
  33. PR 9934: It is possible to have relocations that do not refer to
  34. symbols, thus it is also possible to have a relocation section in
  35. an object file, but no symbol table. */
  36. #define NUM_SHDR_ENTRIES(shdr) ((shdr)->sh_entsize > 0 ? (shdr)->sh_size / (shdr)->sh_entsize : 0)
  37. /* If size isn't specified as 64 or 32, NAME macro should fail. */
  38. #ifndef NAME
  39. #if ARCH_SIZE == 64
  40. #define NAME(x, y) x ## 64 ## _ ## y
  41. #endif
  42. #if ARCH_SIZE == 32
  43. #define NAME(x, y) x ## 32 ## _ ## y
  44. #endif
  45. #endif
  46. #ifndef NAME
  47. #define NAME(x, y) x ## NOSIZE ## _ ## y
  48. #endif
  49. #define ElfNAME(X) NAME(Elf,X)
  50. #define elfNAME(X) NAME(elf,X)
  51. /* Information held for an ELF symbol. The first field is the
  52. corresponding asymbol. Every symbol is an ELF file is actually a
  53. pointer to this structure, although it is often handled as a
  54. pointer to an asymbol. */
  55. typedef struct
  56. {
  57. /* The BFD symbol. */
  58. asymbol symbol;
  59. /* ELF symbol information. */
  60. Elf_Internal_Sym internal_elf_sym;
  61. /* Backend specific information. */
  62. union
  63. {
  64. unsigned int hppa_arg_reloc;
  65. void *mips_extr;
  66. void *any;
  67. }
  68. tc_data;
  69. /* Version information. This is from an Elf_Internal_Versym
  70. structure in a SHT_GNU_versym section. It is zero if there is no
  71. version information. */
  72. unsigned short version;
  73. } elf_symbol_type;
  74. struct elf_strtab_hash;
  75. struct got_entry;
  76. struct plt_entry;
  77. union gotplt_union
  78. {
  79. bfd_signed_vma refcount;
  80. bfd_vma offset;
  81. struct got_entry *glist;
  82. struct plt_entry *plist;
  83. };
  84. struct elf_link_virtual_table_entry
  85. {
  86. /* Virtual table entry use information. This array is nominally of size
  87. size/sizeof(target_void_pointer), though we have to be able to assume
  88. and track a size while the symbol is still undefined. It is indexed
  89. via offset/sizeof(target_void_pointer). */
  90. size_t size;
  91. bool *used;
  92. /* Virtual table derivation info. */
  93. struct elf_link_hash_entry *parent;
  94. };
  95. /* ELF symbol version. */
  96. enum elf_symbol_version
  97. {
  98. unknown = 0,
  99. unversioned,
  100. versioned,
  101. versioned_hidden
  102. };
  103. /* ELF linker hash table entries. */
  104. struct elf_link_hash_entry
  105. {
  106. struct bfd_link_hash_entry root;
  107. /* Symbol index in output file. This is initialized to -1. It is
  108. set to -2 if the symbol is used by a reloc. It is set to -3 if
  109. this symbol is defined in a discarded section. */
  110. long indx;
  111. /* Symbol index as a dynamic symbol. Initialized to -1, and remains
  112. -1 if this is not a dynamic symbol. */
  113. /* ??? Note that this is consistently used as a synonym for tests
  114. against whether we can perform various simplifying transformations
  115. to the code. (E.g. changing a pc-relative jump to a PLT entry
  116. into a pc-relative jump to the target function.) That test, which
  117. is often relatively complex, and someplaces wrong or incomplete,
  118. should really be replaced by a predicate in elflink.c.
  119. End result: this field -1 does not indicate that the symbol is
  120. not in the dynamic symbol table, but rather that the symbol is
  121. not visible outside this DSO. */
  122. long dynindx;
  123. /* If this symbol requires an entry in the global offset table, the
  124. processor specific backend uses this field to track usage and
  125. final offset. Two schemes are supported: The first assumes that
  126. a symbol may only have one GOT entry, and uses REFCOUNT until
  127. size_dynamic_sections, at which point the contents of the .got is
  128. fixed. Afterward, if OFFSET is -1, then the symbol does not
  129. require a global offset table entry. The second scheme allows
  130. multiple GOT entries per symbol, managed via a linked list
  131. pointed to by GLIST. */
  132. union gotplt_union got;
  133. /* Same, but tracks a procedure linkage table entry. */
  134. union gotplt_union plt;
  135. /* Symbol size. NB: All fields starting from here are cleared by
  136. _bfd_elf_link_hash_newfunc. */
  137. bfd_size_type size;
  138. /* Track dynamic relocs copied for this symbol. */
  139. struct elf_dyn_relocs *dyn_relocs;
  140. /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.). */
  141. unsigned int type : 8;
  142. /* Symbol st_other value, symbol visibility. */
  143. unsigned int other : 8;
  144. /* The symbol's st_target_internal value (see Elf_Internal_Sym). */
  145. unsigned int target_internal : 8;
  146. /* Symbol is referenced by a non-shared object (other than the object
  147. in which it is defined). */
  148. unsigned int ref_regular : 1;
  149. /* Symbol is defined by a non-shared object. */
  150. unsigned int def_regular : 1;
  151. /* Symbol is referenced by a shared object. */
  152. unsigned int ref_dynamic : 1;
  153. /* Symbol is defined by a shared object. */
  154. unsigned int def_dynamic : 1;
  155. /* Symbol has a non-weak reference from a non-shared object (other than
  156. the object in which it is defined). */
  157. unsigned int ref_regular_nonweak : 1;
  158. /* Symbol has a non-weak reference from a LTO IR object file. */
  159. unsigned int ref_ir_nonweak : 1;
  160. /* Dynamic symbol has been adjustd. */
  161. unsigned int dynamic_adjusted : 1;
  162. /* Symbol needs a copy reloc. */
  163. unsigned int needs_copy : 1;
  164. /* Symbol needs a procedure linkage table entry. */
  165. unsigned int needs_plt : 1;
  166. /* Symbol appears in a non-ELF input file. */
  167. unsigned int non_elf : 1;
  168. /* Symbol version information. */
  169. ENUM_BITFIELD (elf_symbol_version) versioned : 2;
  170. /* Symbol was forced to local scope due to a version script file. */
  171. unsigned int forced_local : 1;
  172. /* Symbol was forced to be dynamic due to a version script file. */
  173. unsigned int dynamic : 1;
  174. /* Symbol was marked during garbage collection. */
  175. unsigned int mark : 1;
  176. /* Symbol is referenced by a non-GOT/non-PLT relocation. This is
  177. not currently set by all the backends. */
  178. unsigned int non_got_ref : 1;
  179. /* Symbol has a definition in a shared object.
  180. FIXME: There is no real need for this field if def_dynamic is never
  181. cleared and all places that test def_dynamic also test def_regular. */
  182. unsigned int dynamic_def : 1;
  183. /* Symbol has a non-weak reference from a shared object. */
  184. unsigned int ref_dynamic_nonweak : 1;
  185. /* Symbol is referenced with a relocation where C/C++ pointer equality
  186. matters. */
  187. unsigned int pointer_equality_needed : 1;
  188. /* Symbol is a unique global symbol. */
  189. unsigned int unique_global : 1;
  190. /* Symbol is defined by a shared library with non-default visibility
  191. in a read/write section. */
  192. unsigned int protected_def : 1;
  193. /* Symbol is __start_SECNAME or __stop_SECNAME to mark section
  194. SECNAME. */
  195. unsigned int start_stop : 1;
  196. /* Symbol is or was a weak defined symbol from a dynamic object with
  197. a strong defined symbol alias. U.ALIAS points to a list of aliases,
  198. the definition having is_weakalias clear. */
  199. unsigned int is_weakalias : 1;
  200. /* String table index in .dynstr if this is a dynamic symbol. */
  201. unsigned long dynstr_index;
  202. union
  203. {
  204. /* Points to a circular list of non-function symbol aliases. */
  205. struct elf_link_hash_entry *alias;
  206. /* Hash value of the name computed using the ELF hash function.
  207. Used part way through size_dynamic_sections, after we've finished
  208. with aliases. */
  209. unsigned long elf_hash_value;
  210. } u;
  211. /* Version information. */
  212. union
  213. {
  214. /* This field is used for a symbol which is not defined in a
  215. regular object. It points to the version information read in
  216. from the dynamic object. */
  217. Elf_Internal_Verdef *verdef;
  218. /* This field is used for a symbol which is defined in a regular
  219. object. It is set up in size_dynamic_sections. It points to
  220. the version information we should write out for this symbol. */
  221. struct bfd_elf_version_tree *vertree;
  222. } verinfo;
  223. union
  224. {
  225. /* For __start_SECNAME and __stop_SECNAME symbols, record the first
  226. input section whose section name is SECNAME. */
  227. asection *start_stop_section;
  228. /* Vtable information. */
  229. struct elf_link_virtual_table_entry *vtable;
  230. } u2;
  231. };
  232. /* Return the strong definition for a weak symbol with aliases. */
  233. static inline struct elf_link_hash_entry *
  234. weakdef (struct elf_link_hash_entry *h)
  235. {
  236. while (h->is_weakalias)
  237. h = h->u.alias;
  238. return h;
  239. }
  240. /* Will references to this symbol always reference the symbol
  241. in this object? */
  242. #define SYMBOL_REFERENCES_LOCAL(INFO, H) \
  243. _bfd_elf_symbol_refs_local_p (H, INFO, 0)
  244. /* Will _calls_ to this symbol always call the version in this object? */
  245. #define SYMBOL_CALLS_LOCAL(INFO, H) \
  246. _bfd_elf_symbol_refs_local_p (H, INFO, 1)
  247. /* Whether an undefined weak symbol should resolve to its link-time
  248. value, even in PIC or PIE objects. The linker_def test is to
  249. handle symbols like __ehdr_start that may be undefweak in early
  250. stages of linking but are guaranteed to be defined later. */
  251. #define UNDEFWEAK_NO_DYNAMIC_RELOC(INFO, H) \
  252. ((H)->root.type == bfd_link_hash_undefweak \
  253. && !(H)->root.linker_def \
  254. && (ELF_ST_VISIBILITY ((H)->other) != STV_DEFAULT \
  255. || (INFO)->dynamic_undefined_weak == 0))
  256. /* Common symbols that are turned into definitions don't have the
  257. DEF_REGULAR flag set, so they might appear to be undefined.
  258. Symbols defined in linker scripts also don't have DEF_REGULAR set. */
  259. #define ELF_COMMON_DEF_P(H) \
  260. (!(H)->def_regular \
  261. && !(H)->def_dynamic \
  262. && (H)->root.type == bfd_link_hash_defined)
  263. /* Records local symbols to be emitted in the dynamic symbol table. */
  264. struct elf_link_local_dynamic_entry
  265. {
  266. struct elf_link_local_dynamic_entry *next;
  267. /* The input bfd this symbol came from. */
  268. bfd *input_bfd;
  269. /* The index of the local symbol being copied. */
  270. long input_indx;
  271. /* The index in the outgoing dynamic symbol table. */
  272. long dynindx;
  273. /* A copy of the input symbol. */
  274. Elf_Internal_Sym isym;
  275. };
  276. struct elf_link_loaded_list
  277. {
  278. struct elf_link_loaded_list *next;
  279. bfd *abfd;
  280. };
  281. /* Structures used by the eh_frame optimization code. */
  282. struct eh_cie_fde
  283. {
  284. union {
  285. struct {
  286. /* If REMOVED == 1, this is the CIE that the FDE originally used.
  287. The CIE belongs to the same .eh_frame input section as the FDE.
  288. If REMOVED == 0, this is the CIE that we have chosen to use for
  289. the output FDE. The CIE's REMOVED field is also 0, but the CIE
  290. might belong to a different .eh_frame input section from the FDE.
  291. May be NULL to signify that the FDE should be discarded. */
  292. struct eh_cie_fde *cie_inf;
  293. struct eh_cie_fde *next_for_section;
  294. } fde;
  295. struct {
  296. /* CIEs have three states:
  297. - REMOVED && !MERGED: Slated for removal because we haven't yet
  298. proven that an FDE needs it. FULL_CIE, if nonnull, points to
  299. more detailed information about the CIE.
  300. - REMOVED && MERGED: We have merged this CIE with MERGED_WITH,
  301. which may not belong to the same input section.
  302. - !REMOVED: We have decided to keep this CIE. SEC is the
  303. .eh_frame input section that contains the CIE. */
  304. union {
  305. struct cie *full_cie;
  306. struct eh_cie_fde *merged_with;
  307. asection *sec;
  308. } u;
  309. /* The offset of the personality data from the start of the CIE,
  310. or 0 if the CIE doesn't have any. */
  311. unsigned int personality_offset : 8;
  312. /* Length of augmentation. aug_str_len is the length of the
  313. string including null terminator. aug_data_len is the length
  314. of the rest up to the initial insns. */
  315. unsigned int aug_str_len : 3;
  316. unsigned int aug_data_len : 5;
  317. /* True if we have marked relocations associated with this CIE. */
  318. unsigned int gc_mark : 1;
  319. /* True if we have decided to turn an absolute LSDA encoding into
  320. a PC-relative one. */
  321. unsigned int make_lsda_relative : 1;
  322. /* True if we have decided to turn an absolute personality
  323. encoding into a PC-relative one. */
  324. unsigned int make_per_encoding_relative : 1;
  325. /* True if the CIE contains personality data and if that
  326. data uses a PC-relative encoding. Always true when
  327. make_per_encoding_relative is. */
  328. unsigned int per_encoding_relative : 1;
  329. /* True if the CIE contains personality data aligned to a
  330. multiple of eight bytes. */
  331. unsigned int per_encoding_aligned8 : 1;
  332. /* True if we need to add an 'R' (FDE encoding) entry to the
  333. CIE's augmentation data. */
  334. unsigned int add_fde_encoding : 1;
  335. /* True if we have merged this CIE with another. */
  336. unsigned int merged : 1;
  337. /* Unused bits. */
  338. unsigned int pad1 : 9;
  339. } cie;
  340. } u;
  341. unsigned int reloc_index;
  342. unsigned int size;
  343. unsigned int offset;
  344. unsigned int new_offset;
  345. unsigned int fde_encoding : 8;
  346. unsigned int lsda_encoding : 8;
  347. unsigned int lsda_offset : 8;
  348. /* True if this entry represents a CIE, false if it represents an FDE. */
  349. unsigned int cie : 1;
  350. /* True if this entry is currently marked for removal. */
  351. unsigned int removed : 1;
  352. /* True if we need to add a 'z' (augmentation size) entry to the CIE's
  353. augmentation data, and an associated byte to each of the CIE's FDEs. */
  354. unsigned int add_augmentation_size : 1;
  355. /* True if we have decided to convert absolute FDE relocations into
  356. relative ones. This applies to the first relocation in the FDE,
  357. which is against the code that the FDE describes. */
  358. unsigned int make_relative : 1;
  359. /* Unused bits. */
  360. unsigned int pad1 : 4;
  361. unsigned int *set_loc;
  362. };
  363. struct eh_frame_sec_info
  364. {
  365. unsigned int count;
  366. struct cie *cies;
  367. struct eh_cie_fde entry[1];
  368. };
  369. struct eh_frame_array_ent
  370. {
  371. bfd_vma initial_loc;
  372. bfd_size_type range;
  373. bfd_vma fde;
  374. };
  375. struct htab;
  376. #define DWARF2_EH_HDR 1
  377. #define COMPACT_EH_HDR 2
  378. /* Endian-neutral code indicating that a function cannot be unwound. */
  379. #define COMPACT_EH_CANT_UNWIND_OPCODE 0x015d5d01
  380. struct dwarf_eh_frame_hdr_info
  381. {
  382. struct htab *cies;
  383. unsigned int fde_count;
  384. /* TRUE if .eh_frame_hdr should contain the sorted search table.
  385. We build it if we successfully read all .eh_frame input sections
  386. and recognize them. */
  387. bool table;
  388. struct eh_frame_array_ent *array;
  389. };
  390. struct compact_eh_frame_hdr_info
  391. {
  392. unsigned int allocated_entries;
  393. /* eh_frame_entry fragments. */
  394. asection **entries;
  395. };
  396. struct eh_frame_hdr_info
  397. {
  398. asection *hdr_sec;
  399. unsigned int array_count;
  400. bool frame_hdr_is_compact;
  401. union
  402. {
  403. struct dwarf_eh_frame_hdr_info dwarf;
  404. struct compact_eh_frame_hdr_info compact;
  405. }
  406. u;
  407. };
  408. /* Enum used to identify target specific extensions to the elf_obj_tdata
  409. and elf_link_hash_table structures. Note the enums deliberately start
  410. from 1 so that we can detect an uninitialized field. The generic value
  411. is last so that additions to this enum do not need to modify more than
  412. one line. */
  413. enum elf_target_id
  414. {
  415. AARCH64_ELF_DATA = 1,
  416. ALPHA_ELF_DATA,
  417. AMDGCN_ELF_DATA,
  418. ARC_ELF_DATA,
  419. ARM_ELF_DATA,
  420. AVR_ELF_DATA,
  421. BFIN_ELF_DATA,
  422. CRIS_ELF_DATA,
  423. CSKY_ELF_DATA,
  424. FRV_ELF_DATA,
  425. HPPA32_ELF_DATA,
  426. HPPA64_ELF_DATA,
  427. I386_ELF_DATA,
  428. IA64_ELF_DATA,
  429. LM32_ELF_DATA,
  430. LARCH_ELF_DATA,
  431. M32R_ELF_DATA,
  432. M68HC11_ELF_DATA,
  433. M68K_ELF_DATA,
  434. METAG_ELF_DATA,
  435. MICROBLAZE_ELF_DATA,
  436. MIPS_ELF_DATA,
  437. MN10300_ELF_DATA,
  438. NDS32_ELF_DATA,
  439. NIOS2_ELF_DATA,
  440. OR1K_ELF_DATA,
  441. PPC32_ELF_DATA,
  442. PPC64_ELF_DATA,
  443. PRU_ELF_DATA,
  444. S390_ELF_DATA,
  445. SH_ELF_DATA,
  446. SPARC_ELF_DATA,
  447. SPU_ELF_DATA,
  448. TIC6X_ELF_DATA,
  449. X86_64_ELF_DATA,
  450. XTENSA_ELF_DATA,
  451. TILEGX_ELF_DATA,
  452. TILEPRO_ELF_DATA,
  453. RISCV_ELF_DATA,
  454. GENERIC_ELF_DATA
  455. };
  456. struct elf_sym_strtab
  457. {
  458. Elf_Internal_Sym sym;
  459. unsigned long dest_index;
  460. };
  461. struct bfd_link_needed_list
  462. {
  463. struct bfd_link_needed_list *next;
  464. bfd *by;
  465. const char *name;
  466. };
  467. enum elf_target_os
  468. {
  469. is_normal,
  470. is_solaris, /* Solaris. */
  471. is_vxworks, /* VxWorks. */
  472. is_nacl /* Native Client. */
  473. };
  474. /* Used by bfd_sym_from_r_symndx to cache a small number of local
  475. symbols. */
  476. #define LOCAL_SYM_CACHE_SIZE 32
  477. struct sym_cache
  478. {
  479. bfd *abfd;
  480. unsigned long indx[LOCAL_SYM_CACHE_SIZE];
  481. Elf_Internal_Sym sym[LOCAL_SYM_CACHE_SIZE];
  482. };
  483. /* ELF linker hash table. */
  484. struct elf_link_hash_table
  485. {
  486. struct bfd_link_hash_table root;
  487. /* An identifier used to distinguish different target
  488. specific extensions to this structure. */
  489. enum elf_target_id hash_table_id;
  490. /* Whether we have created the special dynamic sections required
  491. when linking against or generating a shared object. */
  492. bool dynamic_sections_created;
  493. /* Whether dynamic relocations are present. */
  494. bool dynamic_relocs;
  495. /* True if this target has relocatable executables, so needs dynamic
  496. section symbols. */
  497. bool is_relocatable_executable;
  498. /* TRUE if there are IFUNC resolvers. */
  499. bool ifunc_resolvers;
  500. /* TRUE if DT_PLTGOT is a required dynamic tag. */
  501. bool dt_pltgot_required;
  502. /* TRUE if DT_JMPREL is a required dynamic tag. */
  503. bool dt_jmprel_required;
  504. /* TRUE when we are handling DT_NEEDED entries. */
  505. bool handling_dt_needed;
  506. /* The BFD used to hold special sections created by the linker.
  507. This will be the first BFD found which requires these sections to
  508. be created. */
  509. bfd *dynobj;
  510. /* The value to use when initialising got.refcount/offset and
  511. plt.refcount/offset in an elf_link_hash_entry. Set to zero when
  512. the values are refcounts. Set to init_got_offset/init_plt_offset
  513. in size_dynamic_sections when the values may be offsets. */
  514. union gotplt_union init_got_refcount;
  515. union gotplt_union init_plt_refcount;
  516. /* The value to use for got.refcount/offset and plt.refcount/offset
  517. when the values may be offsets. Normally (bfd_vma) -1. */
  518. union gotplt_union init_got_offset;
  519. union gotplt_union init_plt_offset;
  520. /* The number of symbols found in the link which is intended for the
  521. mandatory DT_SYMTAB tag (.dynsym section) in .dynamic section. */
  522. bfd_size_type dynsymcount;
  523. bfd_size_type local_dynsymcount;
  524. /* The string table of dynamic symbols, which becomes the .dynstr
  525. section. */
  526. struct elf_strtab_hash *dynstr;
  527. /* The array size of the symbol string table, which becomes the
  528. .strtab section. */
  529. bfd_size_type strtabsize;
  530. /* The array of strings, which becomes the .strtab section. */
  531. struct elf_sym_strtab *strtab;
  532. /* The number of buckets in the hash table in the .hash section.
  533. This is based on the number of dynamic symbols. */
  534. bfd_size_type bucketcount;
  535. /* A linked list of DT_NEEDED names found in dynamic objects
  536. included in the link. */
  537. struct bfd_link_needed_list *needed;
  538. /* Sections in the output bfd that provides a section symbol
  539. to be used by relocations emitted against local symbols.
  540. Most targets will not use data_index_section. */
  541. asection *text_index_section;
  542. asection *data_index_section;
  543. /* The _GLOBAL_OFFSET_TABLE_ symbol. */
  544. struct elf_link_hash_entry *hgot;
  545. /* The _PROCEDURE_LINKAGE_TABLE_ symbol. */
  546. struct elf_link_hash_entry *hplt;
  547. /* The _DYNAMIC symbol. */
  548. struct elf_link_hash_entry *hdynamic;
  549. /* A pointer to information used to merge SEC_MERGE sections. */
  550. void *merge_info;
  551. /* Used to link stabs in sections. */
  552. struct stab_info stab_info;
  553. /* Used by eh_frame code when editing .eh_frame. */
  554. struct eh_frame_hdr_info eh_info;
  555. /* A linked list of local symbols to be added to .dynsym. */
  556. struct elf_link_local_dynamic_entry *dynlocal;
  557. /* A linked list of DT_RPATH/DT_RUNPATH names found in dynamic
  558. objects included in the link. */
  559. struct bfd_link_needed_list *runpath;
  560. /* Cached first output tls section and size of PT_TLS segment. */
  561. asection *tls_sec;
  562. bfd_size_type tls_size; /* Bytes. */
  563. /* The offset into splt of the PLT entry for the TLS descriptor
  564. resolver. Special values are 0, if not necessary (or not found
  565. to be necessary yet), and -1 if needed but not determined
  566. yet. */
  567. bfd_vma tlsdesc_plt;
  568. /* The GOT offset for the lazy trampoline. Communicated to the
  569. loader via DT_TLSDESC_GOT. The magic value (bfd_vma) -1
  570. indicates an offset is not allocated. */
  571. bfd_vma tlsdesc_got;
  572. /* Target OS for linker output. */
  573. enum elf_target_os target_os;
  574. /* A linked list of dynamic BFD's loaded in the link. */
  575. struct elf_link_loaded_list *dyn_loaded;
  576. /* Small local sym cache. */
  577. struct sym_cache sym_cache;
  578. /* Short-cuts to get to dynamic linker sections. */
  579. asection *sgot;
  580. asection *sgotplt;
  581. asection *srelgot;
  582. asection *splt;
  583. asection *srelplt;
  584. asection *sdynbss;
  585. asection *srelbss;
  586. asection *sdynrelro;
  587. asection *sreldynrelro;
  588. asection *igotplt;
  589. asection *iplt;
  590. asection *irelplt;
  591. asection *irelifunc;
  592. asection *dynsym;
  593. asection *srelrdyn;
  594. };
  595. /* Returns TRUE if the hash table is a struct elf_link_hash_table. */
  596. static inline bool
  597. is_elf_hash_table (const struct bfd_link_hash_table *htab)
  598. {
  599. return htab->type == bfd_link_elf_hash_table;
  600. }
  601. /* Look up an entry in an ELF linker hash table. */
  602. static inline struct elf_link_hash_entry *
  603. elf_link_hash_lookup (struct elf_link_hash_table *table, const char *string,
  604. bool create, bool copy, bool follow)
  605. {
  606. if (ENABLE_CHECKING && !is_elf_hash_table (&table->root))
  607. abort ();
  608. return (struct elf_link_hash_entry *)
  609. bfd_link_hash_lookup (&table->root, string, create, copy, follow);
  610. }
  611. /* Traverse an ELF linker hash table. */
  612. static inline void
  613. elf_link_hash_traverse (struct elf_link_hash_table *table,
  614. bool (*f) (struct elf_link_hash_entry *, void *),
  615. void *info)
  616. {
  617. if (ENABLE_CHECKING && !is_elf_hash_table (&table->root))
  618. abort ();
  619. bfd_link_hash_traverse (&table->root,
  620. (bool (*) (struct bfd_link_hash_entry *, void *)) f,
  621. info);
  622. }
  623. /* Get the ELF linker hash table from a link_info structure. */
  624. static inline struct elf_link_hash_table *
  625. elf_hash_table (const struct bfd_link_info *info)
  626. {
  627. return (struct elf_link_hash_table *) info->hash;
  628. }
  629. static inline enum elf_target_id
  630. elf_hash_table_id (const struct elf_link_hash_table *table)
  631. {
  632. return table->hash_table_id;
  633. }
  634. /* Constant information held for an ELF backend. */
  635. struct elf_size_info {
  636. unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
  637. unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
  638. /* The size of entries in the .hash section. */
  639. unsigned char sizeof_hash_entry;
  640. /* The number of internal relocations to allocate per external
  641. relocation entry. */
  642. unsigned char int_rels_per_ext_rel;
  643. /* We use some fixed size arrays. This should be large enough to
  644. handle all back-ends. */
  645. #define MAX_INT_RELS_PER_EXT_REL 3
  646. unsigned char arch_size, log_file_align;
  647. unsigned char elfclass, ev_current;
  648. int (*write_out_phdrs)
  649. (bfd *, const Elf_Internal_Phdr *, unsigned int);
  650. bool (*write_shdrs_and_ehdr) (bfd *);
  651. bool (*checksum_contents)
  652. (bfd * , void (*) (const void *, size_t, void *), void *);
  653. void (*write_relocs)
  654. (bfd *, asection *, void *);
  655. bool (*swap_symbol_in)
  656. (bfd *, const void *, const void *, Elf_Internal_Sym *);
  657. void (*swap_symbol_out)
  658. (bfd *, const Elf_Internal_Sym *, void *, void *);
  659. bool (*slurp_reloc_table)
  660. (bfd *, asection *, asymbol **, bool);
  661. long (*slurp_symbol_table)
  662. (bfd *, asymbol **, bool);
  663. void (*swap_dyn_in)
  664. (bfd *, const void *, Elf_Internal_Dyn *);
  665. void (*swap_dyn_out)
  666. (bfd *, const Elf_Internal_Dyn *, void *);
  667. /* This function is called to swap in a REL relocation. If an
  668. external relocation corresponds to more than one internal
  669. relocation, then all relocations are swapped in at once. */
  670. void (*swap_reloc_in)
  671. (bfd *, const bfd_byte *, Elf_Internal_Rela *);
  672. /* This function is called to swap out a REL relocation. */
  673. void (*swap_reloc_out)
  674. (bfd *, const Elf_Internal_Rela *, bfd_byte *);
  675. /* This function is called to swap in a RELA relocation. If an
  676. external relocation corresponds to more than one internal
  677. relocation, then all relocations are swapped in at once. */
  678. void (*swap_reloca_in)
  679. (bfd *, const bfd_byte *, Elf_Internal_Rela *);
  680. /* This function is called to swap out a RELA relocation. */
  681. void (*swap_reloca_out)
  682. (bfd *, const Elf_Internal_Rela *, bfd_byte *);
  683. };
  684. #define elf_symbol_from(S) \
  685. ((((S)->flags & BSF_SYNTHETIC) == 0 \
  686. && (S)->the_bfd != NULL \
  687. && (S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
  688. && (S)->the_bfd->tdata.elf_obj_data != 0) \
  689. ? (elf_symbol_type *) (S) \
  690. : 0)
  691. enum elf_reloc_type_class {
  692. reloc_class_normal,
  693. reloc_class_relative,
  694. reloc_class_copy,
  695. reloc_class_ifunc,
  696. reloc_class_plt
  697. };
  698. struct elf_reloc_cookie
  699. {
  700. Elf_Internal_Rela *rels, *rel, *relend;
  701. Elf_Internal_Sym *locsyms;
  702. bfd *abfd;
  703. size_t locsymcount;
  704. size_t extsymoff;
  705. struct elf_link_hash_entry **sym_hashes;
  706. int r_sym_shift;
  707. bool bad_symtab;
  708. };
  709. /* The level of IRIX compatibility we're striving for. */
  710. typedef enum {
  711. ict_none,
  712. ict_irix5,
  713. ict_irix6
  714. } irix_compat_t;
  715. /* Mapping of ELF section names and types. */
  716. struct bfd_elf_special_section
  717. {
  718. const char *prefix;
  719. unsigned int prefix_length;
  720. /* 0 means name must match PREFIX exactly.
  721. -1 means name must start with PREFIX followed by an arbitrary string.
  722. -2 means name must match PREFIX exactly or consist of PREFIX followed
  723. by a dot then anything.
  724. > 0 means name must start with the first PREFIX_LENGTH chars of
  725. PREFIX and finish with the last SUFFIX_LENGTH chars of PREFIX. */
  726. signed int suffix_length;
  727. unsigned int type;
  728. bfd_vma attr;
  729. };
  730. enum action_discarded
  731. {
  732. COMPLAIN = 1,
  733. PRETEND = 2
  734. };
  735. typedef asection * (*elf_gc_mark_hook_fn)
  736. (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
  737. struct elf_link_hash_entry *, Elf_Internal_Sym *);
  738. enum elf_property_kind
  739. {
  740. /* A new property. */
  741. property_unknown = 0,
  742. /* A property ignored by backend. */
  743. property_ignored,
  744. /* A corrupt property reported by backend. */
  745. property_corrupt,
  746. /* A property should be removed due to property merge. */
  747. property_remove,
  748. /* A property which is a number. */
  749. property_number
  750. };
  751. typedef struct elf_property
  752. {
  753. unsigned int pr_type;
  754. unsigned int pr_datasz;
  755. union
  756. {
  757. /* For property_number, this is a number. */
  758. bfd_vma number;
  759. /* Add a new one if elf_property_kind is updated. */
  760. } u;
  761. enum elf_property_kind pr_kind;
  762. } elf_property;
  763. typedef struct elf_property_list
  764. {
  765. struct elf_property_list *next;
  766. struct elf_property property;
  767. } elf_property_list;
  768. struct bfd_elf_section_reloc_data;
  769. struct elf_backend_data
  770. {
  771. /* The architecture for this backend. */
  772. enum bfd_architecture arch;
  773. /* An identifier used to distinguish different target specific
  774. extensions to elf_obj_tdata and elf_link_hash_table structures. */
  775. enum elf_target_id target_id;
  776. /* Target OS. */
  777. enum elf_target_os target_os;
  778. /* The ELF machine code (EM_xxxx) for this backend. */
  779. int elf_machine_code;
  780. /* EI_OSABI. */
  781. int elf_osabi;
  782. /* The maximum page size for this backend. */
  783. bfd_vma maxpagesize;
  784. /* The minimum page size for this backend. An input object will not be
  785. considered page aligned unless its sections are correctly aligned for
  786. pages at least this large. May be smaller than maxpagesize. */
  787. bfd_vma minpagesize;
  788. /* The common page size for this backend. */
  789. bfd_vma commonpagesize;
  790. /* The p_align value for this backend. If it is set, p_align of
  791. PT_LOAD alignment will be to p_align by default. */
  792. bfd_vma p_align;
  793. /* The BFD flags applied to sections created for dynamic linking. */
  794. flagword dynamic_sec_flags;
  795. /* Architecture-specific data for this backend.
  796. This is actually a pointer to some type like struct elf_ARCH_data. */
  797. const void *arch_data;
  798. /* A function to translate an ELF RELA relocation to a BFD arelent
  799. structure. Returns TRUE upon success, FALSE otherwise. */
  800. bool (*elf_info_to_howto)
  801. (bfd *, arelent *, Elf_Internal_Rela *);
  802. /* A function to translate an ELF REL relocation to a BFD arelent
  803. structure. Returns TRUE upon success, FALSE otherwise. */
  804. bool (*elf_info_to_howto_rel)
  805. (bfd *, arelent *, Elf_Internal_Rela *);
  806. /* A function to determine whether a symbol is global when
  807. partitioning the symbol table into local and global symbols.
  808. This should be NULL for most targets, in which case the correct
  809. thing will be done. MIPS ELF, at least on the Irix 5, has
  810. special requirements. */
  811. bool (*elf_backend_sym_is_global)
  812. (bfd *, asymbol *);
  813. /* The remaining functions are hooks which are called only if they
  814. are not NULL. */
  815. /* A function to permit a backend specific check on whether a
  816. particular BFD format is relevant for an object file, and to
  817. permit the backend to set any global information it wishes. When
  818. this is called elf_elfheader is set, but anything else should be
  819. used with caution. If this returns FALSE, the check_format
  820. routine will return a bfd_error_wrong_format error. */
  821. bool (*elf_backend_object_p)
  822. (bfd *);
  823. /* A function to do additional symbol processing when reading the
  824. ELF symbol table. This is where any processor-specific special
  825. section indices are handled. */
  826. void (*elf_backend_symbol_processing)
  827. (bfd *, asymbol *);
  828. /* A function to do additional symbol processing after reading the
  829. entire ELF symbol table. */
  830. bool (*elf_backend_symbol_table_processing)
  831. (bfd *, elf_symbol_type *, unsigned int);
  832. /* A function to set the type of the info field. Processor-specific
  833. types should be handled here. */
  834. int (*elf_backend_get_symbol_type)
  835. (Elf_Internal_Sym *, int);
  836. /* A function to return the linker hash table entry of a symbol that
  837. might be satisfied by an archive symbol. */
  838. struct bfd_link_hash_entry * (*elf_backend_archive_symbol_lookup)
  839. (bfd *, struct bfd_link_info *, const char *);
  840. /* Return true if local section symbols should have a non-null st_name.
  841. NULL implies false. */
  842. bool (*elf_backend_name_local_section_symbols)
  843. (bfd *);
  844. /* A function to do additional processing on the ELF section header
  845. just before writing it out. This is used to set the flags and
  846. type fields for some sections, or to actually write out data for
  847. unusual sections. */
  848. bool (*elf_backend_section_processing)
  849. (bfd *, Elf_Internal_Shdr *);
  850. /* A function to handle unusual section types when creating BFD
  851. sections from ELF sections. */
  852. bool (*elf_backend_section_from_shdr)
  853. (bfd *, Elf_Internal_Shdr *, const char *, int);
  854. /* A function to convert machine dependent ELF section header flags to
  855. BFD internal section header flags. */
  856. bool (*elf_backend_section_flags)
  857. (const Elf_Internal_Shdr *);
  858. /* A function that returns a struct containing ELF section flags and
  859. type for the given BFD section. */
  860. const struct bfd_elf_special_section * (*get_sec_type_attr)
  861. (bfd *, asection *);
  862. /* A function to handle unusual program segment types when creating BFD
  863. sections from ELF program segments. */
  864. bool (*elf_backend_section_from_phdr)
  865. (bfd *, Elf_Internal_Phdr *, int, const char *);
  866. /* A function to set up the ELF section header for a BFD section in
  867. preparation for writing it out. This is where the flags and type
  868. fields are set for unusual sections. */
  869. bool (*elf_backend_fake_sections)
  870. (bfd *, Elf_Internal_Shdr *, asection *);
  871. /* A function to get the ELF section index for a BFD section. If
  872. this returns TRUE, the section was found. If it is a normal ELF
  873. section, *RETVAL should be left unchanged. If it is not a normal
  874. ELF section *RETVAL should be set to the SHN_xxxx index. */
  875. bool (*elf_backend_section_from_bfd_section)
  876. (bfd *, asection *, int *retval);
  877. /* If this field is not NULL, it is called by the add_symbols phase
  878. of a link just before adding a symbol to the global linker hash
  879. table. It may modify any of the fields as it wishes. If *NAME
  880. is set to NULL, the symbol will be skipped rather than being
  881. added to the hash table. This function is responsible for
  882. handling all processor dependent symbol bindings and section
  883. indices, and must set at least *FLAGS and *SEC for each processor
  884. dependent case; failure to do so will cause a link error. */
  885. bool (*elf_add_symbol_hook)
  886. (bfd *abfd, struct bfd_link_info *info, Elf_Internal_Sym *,
  887. const char **name, flagword *flags, asection **sec, bfd_vma *value);
  888. /* If this field is not NULL, it is called by the elf_link_output_sym
  889. phase of a link for each symbol which will appear in the object file.
  890. On error, this function returns 0. 1 is returned when the symbol
  891. should be output, 2 is returned when the symbol should be discarded. */
  892. int (*elf_backend_link_output_symbol_hook)
  893. (struct bfd_link_info *info, const char *, Elf_Internal_Sym *,
  894. asection *, struct elf_link_hash_entry *);
  895. /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
  896. linker the first time it encounters a dynamic object in the link.
  897. This function must create any sections required for dynamic
  898. linking. The ABFD argument is a dynamic object. The .interp,
  899. .dynamic, .dynsym, .dynstr, and .hash functions have already been
  900. created, and this function may modify the section flags if
  901. desired. This function will normally create the .got and .plt
  902. sections, but different backends have different requirements. */
  903. bool (*elf_backend_create_dynamic_sections)
  904. (bfd *abfd, struct bfd_link_info *info);
  905. /* When creating a shared library, determine whether to omit the
  906. dynamic symbol for the section. */
  907. bool (*elf_backend_omit_section_dynsym)
  908. (bfd *output_bfd, struct bfd_link_info *info, asection *osec);
  909. /* Return TRUE if relocations of targets are compatible to the extent
  910. that CHECK_RELOCS will properly process them. PR 4424. */
  911. bool (*relocs_compatible) (const bfd_target *, const bfd_target *);
  912. /* The CHECK_RELOCS function is called after all input files have been
  913. opened. It is called once for each section with relocs of an object
  914. file. The function must look through the relocs and do any special
  915. handling required. This generally means allocating space in the
  916. global offset table, and perhaps allocating space for a reloc. The
  917. relocs are always passed as Rela structures; if the section
  918. actually uses Rel structures, the r_addend field will always be
  919. zero. */
  920. bool (*check_relocs)
  921. (bfd *abfd, struct bfd_link_info *info, asection *o,
  922. const Elf_Internal_Rela *relocs);
  923. /* The SIZE_RELATIVE_RELOCS function is called to size relative
  924. relocations when mappig sections to segments. */
  925. bool (*size_relative_relocs)
  926. (struct bfd_link_info *info, bool *need_layout);
  927. /* The FINISH_RELATIVE_RELOCS function is called to finish relative
  928. relocations in bfd_elf_final_link. */
  929. bool (*finish_relative_relocs)
  930. (struct bfd_link_info *info);
  931. /* The CHECK_DIRECTIVES function is called once per input file by
  932. the add_symbols phase of the ELF backend linker. The function
  933. must inspect the bfd and create any additional symbols according
  934. to any custom directives in the bfd. */
  935. bool (*check_directives)
  936. (bfd *abfd, struct bfd_link_info *info);
  937. /* The NOTICE_AS_NEEDED function is called as the linker is about to
  938. handle an as-needed lib (ACT = notice_as_needed), and after the
  939. linker has decided to keep the lib (ACT = notice_needed) or when
  940. the lib is not needed (ACT = notice_not_needed). */
  941. bool (*notice_as_needed)
  942. (bfd *abfd, struct bfd_link_info *info, enum notice_asneeded_action act);
  943. /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
  944. linker for every symbol which is defined by a dynamic object and
  945. referenced by a regular object. This is called after all the
  946. input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
  947. function has been called. The hash table entry should be
  948. bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
  949. defined in a section from a dynamic object. Dynamic object
  950. sections are not included in the final link, and this function is
  951. responsible for changing the value to something which the rest of
  952. the link can deal with. This will normally involve adding an
  953. entry to the .plt or .got or some such section, and setting the
  954. symbol to point to that. */
  955. bool (*elf_backend_adjust_dynamic_symbol)
  956. (struct bfd_link_info *info, struct elf_link_hash_entry *h);
  957. /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
  958. after all the linker input files have been seen but before the
  959. section sizes have been set. This is called after
  960. ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS. */
  961. bool (*elf_backend_always_size_sections)
  962. (bfd *output_bfd, struct bfd_link_info *info);
  963. /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
  964. linker after all the linker input files have been seen but before
  965. the sections sizes have been set. This is called after
  966. ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
  967. It is only called when linking against a dynamic object. It must
  968. set the sizes of the dynamic sections, and may fill in their
  969. contents as well. The generic ELF linker can handle the .dynsym,
  970. .dynstr and .hash sections. This function must handle the
  971. .interp section and any sections created by the
  972. CREATE_DYNAMIC_SECTIONS entry point. */
  973. bool (*elf_backend_size_dynamic_sections)
  974. (bfd *output_bfd, struct bfd_link_info *info);
  975. /* The STRIP_ZERO_SIZED_DYNAMIC_SECTIONS function is called by the
  976. ELF backend linker to strip zero-sized dynamic sections after
  977. the section sizes have been set. */
  978. bool (*elf_backend_strip_zero_sized_dynamic_sections)
  979. (struct bfd_link_info *info);
  980. /* Set TEXT_INDEX_SECTION and DATA_INDEX_SECTION, the output sections
  981. we keep to use as a base for relocs and symbols. */
  982. void (*elf_backend_init_index_section)
  983. (bfd *output_bfd, struct bfd_link_info *info);
  984. /* The RELOCATE_SECTION function is called by the ELF backend linker
  985. to handle the relocations for a section.
  986. The relocs are always passed as Rela structures; if the section
  987. actually uses Rel structures, the r_addend field will always be
  988. zero.
  989. This function is responsible for adjust the section contents as
  990. necessary, and (if using Rela relocs and generating a
  991. relocatable output file) adjusting the reloc addend as
  992. necessary.
  993. This function does not have to worry about setting the reloc
  994. address or the reloc symbol index.
  995. LOCAL_SYMS is a pointer to the swapped in local symbols.
  996. LOCAL_SECTIONS is an array giving the section in the input file
  997. corresponding to the st_shndx field of each local symbol.
  998. The global hash table entry for the global symbols can be found
  999. via elf_sym_hashes (input_bfd).
  1000. When generating relocatable output, this function must handle
  1001. STB_LOCAL/STT_SECTION symbols specially. The output symbol is
  1002. going to be the section symbol corresponding to the output
  1003. section, which means that the addend must be adjusted
  1004. accordingly.
  1005. Returns FALSE on error, TRUE on success, 2 if successful and
  1006. relocations should be written for this section. */
  1007. int (*elf_backend_relocate_section)
  1008. (bfd *output_bfd, struct bfd_link_info *info, bfd *input_bfd,
  1009. asection *input_section, bfd_byte *contents, Elf_Internal_Rela *relocs,
  1010. Elf_Internal_Sym *local_syms, asection **local_sections);
  1011. /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
  1012. linker just before it writes a symbol out to the .dynsym section.
  1013. The processor backend may make any required adjustment to the
  1014. symbol. It may also take the opportunity to set contents of the
  1015. dynamic sections. Note that FINISH_DYNAMIC_SYMBOL is called on
  1016. all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
  1017. on those symbols which are defined by a dynamic object. */
  1018. bool (*elf_backend_finish_dynamic_symbol)
  1019. (bfd *output_bfd, struct bfd_link_info *info,
  1020. struct elf_link_hash_entry *h, Elf_Internal_Sym *sym);
  1021. /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
  1022. linker just before it writes all the dynamic sections out to the
  1023. output file. The FINISH_DYNAMIC_SYMBOL will have been called on
  1024. all dynamic symbols. */
  1025. bool (*elf_backend_finish_dynamic_sections)
  1026. (bfd *output_bfd, struct bfd_link_info *info);
  1027. /* A function to do any beginning processing needed for the ELF file
  1028. before building the ELF headers and computing file positions. */
  1029. void (*elf_backend_begin_write_processing)
  1030. (bfd *, struct bfd_link_info *);
  1031. /* A function to do any final processing needed for the ELF file
  1032. before writing it out. */
  1033. bool (*elf_backend_final_write_processing)
  1034. (bfd *);
  1035. /* This function is called by get_program_header_size. It should
  1036. return the number of additional program segments which this BFD
  1037. will need. It should return -1 on error. */
  1038. int (*elf_backend_additional_program_headers)
  1039. (bfd *, struct bfd_link_info *);
  1040. /* This function is called to modify an existing segment map in a
  1041. backend specific fashion. */
  1042. bool (*elf_backend_modify_segment_map)
  1043. (bfd *, struct bfd_link_info *);
  1044. /* This function is called to modify program headers just before
  1045. they are written. */
  1046. bool (*elf_backend_modify_headers)
  1047. (bfd *, struct bfd_link_info *);
  1048. /* This function is called to see if the PHDR header should be
  1049. checked for validity. */
  1050. bool (*elf_backend_allow_non_load_phdr)
  1051. (bfd *, const Elf_Internal_Phdr *, unsigned);
  1052. /* This function is called before section garbage collection to
  1053. mark entry symbol sections. */
  1054. void (*gc_keep)
  1055. (struct bfd_link_info *);
  1056. /* This function is called during section garbage collection to
  1057. mark sections that define global symbols. */
  1058. bool (*gc_mark_dynamic_ref)
  1059. (struct elf_link_hash_entry *, void *);
  1060. /* This function is called during section gc to discover the section a
  1061. particular relocation refers to. */
  1062. elf_gc_mark_hook_fn gc_mark_hook;
  1063. /* This function, if defined, is called after the first gc marking pass
  1064. to allow the backend to mark additional sections. */
  1065. bool (*gc_mark_extra_sections)
  1066. (struct bfd_link_info *, elf_gc_mark_hook_fn);
  1067. /* This function is called to initialise ELF file header info.
  1068. Customised versions can modify things like the OS and ABI version. */
  1069. bool (*elf_backend_init_file_header)
  1070. (bfd *, struct bfd_link_info *);
  1071. /* This function, if defined, prints a symbol to file and returns the
  1072. name of the symbol to be printed. It should return NULL to fall
  1073. back to default symbol printing. */
  1074. const char *(*elf_backend_print_symbol_all)
  1075. (bfd *, void *, asymbol *);
  1076. /* This function, if defined, is called after all local symbols and
  1077. global symbols converted to locals are emitted into the symtab
  1078. section. It allows the backend to emit special local symbols
  1079. not handled in the hash table. */
  1080. bool (*elf_backend_output_arch_local_syms)
  1081. (bfd *, struct bfd_link_info *, void *,
  1082. int (*) (void *, const char *, Elf_Internal_Sym *, asection *,
  1083. struct elf_link_hash_entry *));
  1084. /* This function, if defined, is called after all symbols are emitted
  1085. into the symtab section. It allows the backend to emit special
  1086. global symbols not handled in the hash table. */
  1087. bool (*elf_backend_output_arch_syms)
  1088. (bfd *, struct bfd_link_info *, void *,
  1089. int (*) (void *, const char *, Elf_Internal_Sym *, asection *,
  1090. struct elf_link_hash_entry *));
  1091. /* Filter what symbols of the output file to include in the import
  1092. library if one is created. */
  1093. unsigned int (*elf_backend_filter_implib_symbols)
  1094. (bfd *, struct bfd_link_info *, asymbol **, long);
  1095. /* Copy any information related to dynamic linking from a pre-existing
  1096. symbol to a newly created symbol. Also called to copy flags and
  1097. other back-end info to a weakdef, in which case the symbol is not
  1098. newly created and plt/got refcounts and dynamic indices should not
  1099. be copied. */
  1100. void (*elf_backend_copy_indirect_symbol)
  1101. (struct bfd_link_info *, struct elf_link_hash_entry *,
  1102. struct elf_link_hash_entry *);
  1103. /* Modify any information related to dynamic linking such that the
  1104. symbol is not exported. */
  1105. void (*elf_backend_hide_symbol)
  1106. (struct bfd_link_info *, struct elf_link_hash_entry *, bool);
  1107. /* A function to do additional symbol fixup, called by
  1108. _bfd_elf_fix_symbol_flags. */
  1109. bool (*elf_backend_fixup_symbol)
  1110. (struct bfd_link_info *, struct elf_link_hash_entry *);
  1111. /* Merge the backend specific symbol attribute. */
  1112. void (*elf_backend_merge_symbol_attribute)
  1113. (struct elf_link_hash_entry *, unsigned int, bool, bool);
  1114. /* This function, if defined, will return a string containing the
  1115. name of a target-specific dynamic tag. */
  1116. char *(*elf_backend_get_target_dtag)
  1117. (bfd_vma);
  1118. /* Decide whether an undefined symbol is special and can be ignored.
  1119. This is the case for OPTIONAL symbols on IRIX. */
  1120. bool (*elf_backend_ignore_undef_symbol)
  1121. (struct elf_link_hash_entry *);
  1122. /* Emit relocations. Overrides default routine for emitting relocs,
  1123. except during a relocatable link, or if all relocs are being emitted. */
  1124. bool (*elf_backend_emit_relocs)
  1125. (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,
  1126. struct elf_link_hash_entry **);
  1127. /* Update relocations. It is allowed to change the number and the order.
  1128. In such a case hashes should be invalidated. */
  1129. void (*elf_backend_update_relocs)
  1130. (asection *, struct bfd_elf_section_reloc_data *);
  1131. /* Count relocations. Not called for relocatable links
  1132. or if all relocs are being preserved in the output. */
  1133. unsigned int (*elf_backend_count_relocs)
  1134. (struct bfd_link_info *, asection *);
  1135. /* Count additionals relocations. Called for relocatable links if
  1136. additional relocations needs to be created. */
  1137. unsigned int (*elf_backend_count_additional_relocs)
  1138. (asection *);
  1139. /* Say whether to sort relocs output by ld -r and ld --emit-relocs,
  1140. by r_offset. If NULL, default to true. */
  1141. bool (*sort_relocs_p)
  1142. (asection *);
  1143. /* This function, if defined, is called when an NT_PRSTATUS note is found
  1144. in a core file. */
  1145. bool (*elf_backend_grok_prstatus)
  1146. (bfd *, Elf_Internal_Note *);
  1147. /* This function, if defined, is called when an NT_PSINFO or NT_PRPSINFO
  1148. note is found in a core file. */
  1149. bool (*elf_backend_grok_psinfo)
  1150. (bfd *, Elf_Internal_Note *);
  1151. /* This function, if defined, is called when a "FreeBSD" NT_PRSTATUS
  1152. note is found in a core file. */
  1153. bool (*elf_backend_grok_freebsd_prstatus)
  1154. (bfd *, Elf_Internal_Note *);
  1155. /* This function, if defined, is called to write a note to a corefile. */
  1156. char *(*elf_backend_write_core_note)
  1157. (bfd *abfd, char *buf, int *bufsiz, int note_type, ...);
  1158. /* This function, if defined, is called to convert target-specific
  1159. section flag names into hex values. */
  1160. flagword (*elf_backend_lookup_section_flags_hook)
  1161. (char *);
  1162. /* This function returns class of a reloc type. */
  1163. enum elf_reloc_type_class (*elf_backend_reloc_type_class)
  1164. (const struct bfd_link_info *, const asection *, const Elf_Internal_Rela *);
  1165. /* This function, if defined, removes information about discarded functions
  1166. from other sections which mention them. */
  1167. bool (*elf_backend_discard_info)
  1168. (bfd *, struct elf_reloc_cookie *, struct bfd_link_info *);
  1169. /* This function, if defined, signals that the function above has removed
  1170. the discarded relocations for this section. */
  1171. bool (*elf_backend_ignore_discarded_relocs)
  1172. (asection *);
  1173. /* What to do when ld finds relocations against symbols defined in
  1174. discarded sections. */
  1175. unsigned int (*action_discarded)
  1176. (asection *);
  1177. /* This function returns the width of FDE pointers in bytes, or 0 if
  1178. that can't be determined for some reason. The default definition
  1179. goes by the bfd's EI_CLASS. */
  1180. unsigned int (*elf_backend_eh_frame_address_size)
  1181. (bfd *, const asection *);
  1182. /* These functions tell elf-eh-frame whether to attempt to turn
  1183. absolute or lsda encodings into pc-relative ones. The default
  1184. definition enables these transformations. */
  1185. bool (*elf_backend_can_make_relative_eh_frame)
  1186. (bfd *, struct bfd_link_info *, asection *);
  1187. bool (*elf_backend_can_make_lsda_relative_eh_frame)
  1188. (bfd *, struct bfd_link_info *, asection *);
  1189. /* This function returns an encoding after computing the encoded
  1190. value (and storing it in ENCODED) for the given OFFSET into OSEC,
  1191. to be stored in at LOC_OFFSET into the LOC_SEC input section.
  1192. The default definition chooses a 32-bit PC-relative encoding. */
  1193. bfd_byte (*elf_backend_encode_eh_address)
  1194. (bfd *abfd, struct bfd_link_info *info,
  1195. asection *osec, bfd_vma offset,
  1196. asection *loc_sec, bfd_vma loc_offset,
  1197. bfd_vma *encoded);
  1198. /* This function, if defined, may write out the given section.
  1199. Returns TRUE if it did so and FALSE if the caller should. */
  1200. bool (*elf_backend_write_section)
  1201. (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
  1202. /* This function, if defined, returns TRUE if it is section symbols
  1203. only that are considered local for the purpose of partitioning the
  1204. symbol table into local and global symbols. This should be NULL
  1205. for most targets, in which case the correct thing will be done.
  1206. MIPS ELF, at least on the Irix 5, has special requirements. */
  1207. bool (*elf_backend_elfsym_local_is_section)
  1208. (bfd *);
  1209. /* The level of IRIX compatibility we're striving for.
  1210. MIPS ELF specific function. */
  1211. irix_compat_t (*elf_backend_mips_irix_compat)
  1212. (bfd *);
  1213. reloc_howto_type *(*elf_backend_mips_rtype_to_howto)
  1214. (bfd *, unsigned int, bool);
  1215. /* The swapping table to use when dealing with ECOFF information.
  1216. Used for the MIPS ELF .mdebug section. */
  1217. const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
  1218. /* This function implements `bfd_elf_bfd_from_remote_memory';
  1219. see elf.c, elfcode.h. */
  1220. bfd *(*elf_backend_bfd_from_remote_memory)
  1221. (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
  1222. int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr,
  1223. bfd_size_type len));
  1224. bool (*elf_backend_core_find_build_id) (bfd *, bfd_vma);
  1225. /* This function is used by `_bfd_elf_get_synthetic_symtab';
  1226. see elf.c. */
  1227. bfd_vma (*plt_sym_val) (bfd_vma, const asection *, const arelent *);
  1228. /* Is symbol defined in common section? */
  1229. bool (*common_definition) (Elf_Internal_Sym *);
  1230. /* Return a common section index for section. */
  1231. unsigned int (*common_section_index) (asection *);
  1232. /* Return a common section for section. */
  1233. asection *(*common_section) (asection *);
  1234. /* Return TRUE if we can merge 2 definitions. */
  1235. bool (*merge_symbol) (struct elf_link_hash_entry *,
  1236. const Elf_Internal_Sym *, asection **,
  1237. bool, bool,
  1238. bfd *, const asection *);
  1239. /* Return TRUE if symbol should be hashed in the `.gnu.hash' section. */
  1240. bool (*elf_hash_symbol) (struct elf_link_hash_entry *);
  1241. /* If non-NULL, called to register the location of XLAT_LOC within
  1242. .MIPS.xhash at which real final dynindx for H will be written.
  1243. If XLAT_LOC is zero, the symbol is not included in
  1244. .MIPS.xhash and no dynindx will be written. */
  1245. void (*record_xhash_symbol)
  1246. (struct elf_link_hash_entry *h, bfd_vma xlat_loc);
  1247. /* Return TRUE if type is a function symbol type. */
  1248. bool (*is_function_type) (unsigned int type);
  1249. /* If the ELF symbol SYM might be a function in SEC, return the
  1250. function size and set *CODE_OFF to the function's entry point,
  1251. otherwise return zero. */
  1252. bfd_size_type (*maybe_function_sym) (const asymbol *sym, asection *sec,
  1253. bfd_vma *code_off);
  1254. /* Given NAME, the name of a relocation section stripped of its
  1255. .rel/.rela prefix, return the section in ABFD to which the
  1256. relocations apply. */
  1257. asection *(*get_reloc_section) (bfd *abfd, const char *name);
  1258. /* Called to set the sh_flags, sh_link and sh_info fields of OSECTION which
  1259. has a type >= SHT_LOOS. Returns TRUE if the fields were initialised,
  1260. FALSE otherwise. Can be called multiple times for a given section,
  1261. until it returns TRUE. Most of the times it is called ISECTION will be
  1262. set to an input section that might be associated with the output section.
  1263. The last time that it is called, ISECTION will be set to NULL. */
  1264. bool (*elf_backend_copy_special_section_fields)
  1265. (const bfd *ibfd, bfd *obfd, const Elf_Internal_Shdr *isection,
  1266. Elf_Internal_Shdr *osection);
  1267. /* Used to handle bad SHF_LINK_ORDER input. */
  1268. void (*link_order_error_handler) (const char *, ...);
  1269. /* Name of the PLT relocation section. */
  1270. const char *relplt_name;
  1271. /* Alternate EM_xxxx machine codes for this backend. */
  1272. int elf_machine_alt1;
  1273. int elf_machine_alt2;
  1274. const struct elf_size_info *s;
  1275. /* An array of target specific special sections. */
  1276. const struct bfd_elf_special_section *special_sections;
  1277. /* The size in bytes of the header for the GOT. This includes the
  1278. so-called reserved entries on some systems. */
  1279. bfd_vma got_header_size;
  1280. /* The size of the GOT entry for the symbol pointed to by H if non-NULL,
  1281. otherwise by the local symbol with index SYMNDX in IBFD. */
  1282. bfd_vma (*got_elt_size) (bfd *, struct bfd_link_info *,
  1283. struct elf_link_hash_entry *h,
  1284. bfd *ibfd, unsigned long symndx);
  1285. /* The vendor name to use for a processor-standard attributes section. */
  1286. const char *obj_attrs_vendor;
  1287. /* The section name to use for a processor-standard attributes section. */
  1288. const char *obj_attrs_section;
  1289. /* Return 1, 2 or 3 to indicate what type of arguments a
  1290. processor-specific tag takes. */
  1291. int (*obj_attrs_arg_type) (int);
  1292. /* The section type to use for an attributes section. */
  1293. unsigned int obj_attrs_section_type;
  1294. /* This function determines the order in which any attributes are
  1295. written. It must be defined for input in the range
  1296. LEAST_KNOWN_OBJ_ATTRIBUTE..NUM_KNOWN_OBJ_ATTRIBUTES-1 (this range
  1297. is used in order to make unity easy). The returned value is the
  1298. actual tag number to place in the input position. */
  1299. int (*obj_attrs_order) (int);
  1300. /* Handle merging unknown attributes; either warn and return TRUE,
  1301. or give an error and return FALSE. */
  1302. bool (*obj_attrs_handle_unknown) (bfd *, int);
  1303. /* Parse GNU properties. Return the property kind. If the property
  1304. is corrupt, issue an error message and return property_corrupt. */
  1305. enum elf_property_kind (*parse_gnu_properties) (bfd *, unsigned int,
  1306. bfd_byte *,
  1307. unsigned int);
  1308. /* Merge GNU properties. Return TRUE if property is updated. */
  1309. bool (*merge_gnu_properties) (struct bfd_link_info *, bfd *, bfd *,
  1310. elf_property *, elf_property *);
  1311. /* Set up GNU properties. */
  1312. bfd *(*setup_gnu_properties) (struct bfd_link_info *);
  1313. /* Fix up GNU properties. */
  1314. void (*fixup_gnu_properties) (struct bfd_link_info *,
  1315. elf_property_list **);
  1316. /* Encoding used for compact EH tables. */
  1317. int (*compact_eh_encoding) (struct bfd_link_info *);
  1318. /* Opcode representing no unwind. */
  1319. int (*cant_unwind_opcode) (struct bfd_link_info *);
  1320. /* Called when emitting an ELF symbol whoes input version had an
  1321. ST_SHNDX field set to a value in the range SHN_LOPROC..SHN_HIOS.
  1322. Returns the value to be installed in the ST_SHNDX field of the
  1323. emitted symbol. If not defined, the value is left unchanged. */
  1324. unsigned int (*symbol_section_index) (bfd *, elf_symbol_type *);
  1325. /* Called when a section has extra reloc sections. */
  1326. bool (*init_secondary_reloc_section) (bfd *, Elf_Internal_Shdr *,
  1327. const char *, unsigned int);
  1328. /* Called when after loading the normal relocs for a section. */
  1329. bool (*slurp_secondary_relocs) (bfd *, asection *, asymbol **, bool);
  1330. /* Called after writing the normal relocs for a section. */
  1331. bool (*write_secondary_relocs) (bfd *, asection *);
  1332. /* This is non-zero if static TLS segments require a special alignment. */
  1333. unsigned static_tls_alignment;
  1334. /* Alignment for the PT_GNU_STACK segment. */
  1335. unsigned stack_align;
  1336. /* Flag bits to assign to a section of type SHT_STRTAB. */
  1337. unsigned long elf_strtab_flags;
  1338. /* This is TRUE if the linker should act like collect and gather
  1339. global constructors and destructors by name. This is TRUE for
  1340. MIPS ELF because the Irix 5 tools can not handle the .init
  1341. section. */
  1342. unsigned collect : 1;
  1343. /* This is TRUE if the linker should ignore changes to the type of a
  1344. symbol. This is TRUE for MIPS ELF because some Irix 5 objects
  1345. record undefined functions as STT_OBJECT although the definitions
  1346. are STT_FUNC. */
  1347. unsigned type_change_ok : 1;
  1348. /* Whether the backend may use REL relocations. (Some backends use
  1349. both REL and RELA relocations, and this flag is set for those
  1350. backends.) */
  1351. unsigned may_use_rel_p : 1;
  1352. /* Whether the backend may use RELA relocations. (Some backends use
  1353. both REL and RELA relocations, and this flag is set for those
  1354. backends.) */
  1355. unsigned may_use_rela_p : 1;
  1356. /* Whether the default relocation type is RELA. If a backend with
  1357. this flag set wants REL relocations for a particular section,
  1358. it must note that explicitly. Similarly, if this flag is clear,
  1359. and the backend wants RELA relocations for a particular
  1360. section. */
  1361. unsigned default_use_rela_p : 1;
  1362. /* True if PLT and copy relocations should be RELA by default. */
  1363. unsigned rela_plts_and_copies_p : 1;
  1364. /* Set if RELA relocations for a relocatable link can be handled by
  1365. generic code. Backends that set this flag need do nothing in the
  1366. backend relocate_section routine for relocatable linking. */
  1367. unsigned rela_normal : 1;
  1368. /* Set if DT_REL/DT_RELA/DT_RELSZ/DT_RELASZ should not include PLT
  1369. relocations. */
  1370. unsigned dtrel_excludes_plt : 1;
  1371. /* TRUE if addresses "naturally" sign extend. This is used when
  1372. swapping in from Elf32 when BFD64. */
  1373. unsigned sign_extend_vma : 1;
  1374. unsigned want_got_plt : 1;
  1375. unsigned plt_readonly : 1;
  1376. unsigned want_plt_sym : 1;
  1377. unsigned plt_not_loaded : 1;
  1378. unsigned plt_alignment : 4;
  1379. unsigned can_gc_sections : 1;
  1380. unsigned can_refcount : 1;
  1381. unsigned want_got_sym : 1;
  1382. unsigned want_dynbss : 1;
  1383. unsigned want_dynrelro : 1;
  1384. /* Targets which do not support physical addressing often require
  1385. that the p_paddr field in the section header to be set to zero.
  1386. This field indicates whether this behavior is required. */
  1387. unsigned want_p_paddr_set_to_zero : 1;
  1388. /* Target has broken hardware and/or kernel that requires pages not
  1389. to be mapped twice with different permissions. */
  1390. unsigned no_page_alias : 1;
  1391. /* True if an object file lacking a .note.GNU-stack section
  1392. should be assumed to be requesting exec stack. At least one
  1393. other file in the link needs to have a .note.GNU-stack section
  1394. for a PT_GNU_STACK segment to be created. */
  1395. unsigned default_execstack : 1;
  1396. /* True if elf_section_data(sec)->this_hdr.contents is sec->rawsize
  1397. in length rather than sec->size in length, if sec->rawsize is
  1398. non-zero and smaller than sec->size. */
  1399. unsigned caches_rawsize : 1;
  1400. /* Address of protected data defined in the shared library may be
  1401. external, i.e., due to copy relocation. */
  1402. unsigned extern_protected_data : 1;
  1403. /* True if `_bfd_elf_link_renumber_dynsyms' must be called even for
  1404. static binaries. */
  1405. unsigned always_renumber_dynsyms : 1;
  1406. /* True if the 32-bit Linux PRPSINFO structure's `pr_uid' and `pr_gid'
  1407. members use a 16-bit data type. */
  1408. unsigned linux_prpsinfo32_ugid16 : 1;
  1409. /* True if the 64-bit Linux PRPSINFO structure's `pr_uid' and `pr_gid'
  1410. members use a 16-bit data type. */
  1411. unsigned linux_prpsinfo64_ugid16 : 1;
  1412. };
  1413. /* Information about reloc sections associated with a bfd_elf_section_data
  1414. structure. */
  1415. struct bfd_elf_section_reloc_data
  1416. {
  1417. /* The ELF header for the reloc section associated with this
  1418. section, if any. */
  1419. Elf_Internal_Shdr *hdr;
  1420. /* The number of relocations currently assigned to HDR. */
  1421. unsigned int count;
  1422. /* The ELF section number of the reloc section. Only used for an
  1423. output file. */
  1424. int idx;
  1425. /* Used by the backend linker to store the symbol hash table entries
  1426. associated with relocs against global symbols. */
  1427. struct elf_link_hash_entry **hashes;
  1428. };
  1429. /* Information stored for each BFD section in an ELF file. This
  1430. structure is allocated by elf_new_section_hook. */
  1431. struct bfd_elf_section_data
  1432. {
  1433. /* The ELF header for this section. */
  1434. Elf_Internal_Shdr this_hdr;
  1435. /* INPUT_SECTION_FLAGS if specified in the linker script. */
  1436. struct flag_info *section_flag_info;
  1437. /* Information about the REL and RELA reloc sections associated
  1438. with this section, if any. */
  1439. struct bfd_elf_section_reloc_data rel, rela;
  1440. /* The ELF section number of this section. */
  1441. int this_idx;
  1442. /* Used by the backend linker when generating a shared library to
  1443. record the dynamic symbol index for a section symbol
  1444. corresponding to this section. A value of 0 means that there is
  1445. no dynamic symbol for this section. */
  1446. int dynindx;
  1447. /* A pointer to the linked-to section for SHF_LINK_ORDER. */
  1448. asection *linked_to;
  1449. /* A pointer to the swapped relocs. If the section uses REL relocs,
  1450. rather than RELA, all the r_addend fields will be zero. This
  1451. pointer may be NULL. It is used by the backend linker. */
  1452. Elf_Internal_Rela *relocs;
  1453. /* A pointer to a linked list tracking dynamic relocs copied for
  1454. local symbols. */
  1455. void *local_dynrel;
  1456. /* A pointer to the bfd section used for dynamic relocs. */
  1457. asection *sreloc;
  1458. union {
  1459. /* Group name, if this section is a member of a group. */
  1460. const char *name;
  1461. /* Group signature sym, if this is the SHT_GROUP section. */
  1462. struct bfd_symbol *id;
  1463. } group;
  1464. /* For a member of a group, points to the SHT_GROUP section.
  1465. NULL for the SHT_GROUP section itself and non-group sections. */
  1466. asection *sec_group;
  1467. /* A linked list of member sections in the group. Circular when used by
  1468. the linker. For the SHT_GROUP section, points at first member. */
  1469. asection *next_in_group;
  1470. /* The FDEs associated with this section. The u.fde.next_in_section
  1471. field acts as a chain pointer. */
  1472. struct eh_cie_fde *fde_list;
  1473. /* Link from a text section to its .eh_frame_entry section. */
  1474. asection *eh_frame_entry;
  1475. /* TRUE if the section has secondary reloc sections associated with it.
  1476. FIXME: In the future it might be better to change this into a list
  1477. of secondary reloc sections, making lookup easier and faster. */
  1478. bool has_secondary_relocs;
  1479. /* A pointer used for various section optimizations. */
  1480. void *sec_info;
  1481. };
  1482. #define elf_section_data(sec) ((struct bfd_elf_section_data*)(sec)->used_by_bfd)
  1483. #define elf_linked_to_section(sec) (elf_section_data(sec)->linked_to)
  1484. #define elf_section_type(sec) (elf_section_data(sec)->this_hdr.sh_type)
  1485. #define elf_section_flags(sec) (elf_section_data(sec)->this_hdr.sh_flags)
  1486. #define elf_section_info(sec) (elf_section_data(sec)->this_hdr.sh_info)
  1487. #define elf_group_name(sec) (elf_section_data(sec)->group.name)
  1488. #define elf_group_id(sec) (elf_section_data(sec)->group.id)
  1489. #define elf_next_in_group(sec) (elf_section_data(sec)->next_in_group)
  1490. #define elf_fde_list(sec) (elf_section_data(sec)->fde_list)
  1491. #define elf_sec_group(sec) (elf_section_data(sec)->sec_group)
  1492. #define elf_section_eh_frame_entry(sec) (elf_section_data(sec)->eh_frame_entry)
  1493. #define xvec_get_elf_backend_data(xvec) \
  1494. ((const struct elf_backend_data *) (xvec)->backend_data)
  1495. #define get_elf_backend_data(abfd) \
  1496. xvec_get_elf_backend_data ((abfd)->xvec)
  1497. /* The least object attributes (within an attributes subsection) known
  1498. for any target. Some code assumes that the value 0 is not used and
  1499. the field for that attribute can instead be used as a marker to
  1500. indicate that attributes have been initialized. */
  1501. #define LEAST_KNOWN_OBJ_ATTRIBUTE 2
  1502. /* The maximum number of known object attributes for any target. */
  1503. #define NUM_KNOWN_OBJ_ATTRIBUTES 77
  1504. /* The value of an object attribute. The type indicates whether the attribute
  1505. holds and integer, a string, or both. It can also indicate that there can
  1506. be no default (i.e. all values must be written to file, even zero), or
  1507. that the value is in error and should not be written to file. */
  1508. typedef struct obj_attribute
  1509. {
  1510. #define ATTR_TYPE_FLAG_INT_VAL (1 << 0)
  1511. #define ATTR_TYPE_FLAG_STR_VAL (1 << 1)
  1512. #define ATTR_TYPE_FLAG_NO_DEFAULT (1 << 2)
  1513. #define ATTR_TYPE_FLAG_ERROR (1 << 3)
  1514. #define ATTR_TYPE_HAS_INT_VAL(TYPE) ((TYPE) & ATTR_TYPE_FLAG_INT_VAL)
  1515. #define ATTR_TYPE_HAS_STR_VAL(TYPE) ((TYPE) & ATTR_TYPE_FLAG_STR_VAL)
  1516. #define ATTR_TYPE_HAS_NO_DEFAULT(TYPE) ((TYPE) & ATTR_TYPE_FLAG_NO_DEFAULT)
  1517. #define ATTR_TYPE_HAS_ERROR(TYPE) ((TYPE) & ATTR_TYPE_FLAG_ERROR)
  1518. int type;
  1519. unsigned int i;
  1520. char *s;
  1521. } obj_attribute;
  1522. typedef struct obj_attribute_list
  1523. {
  1524. struct obj_attribute_list *next;
  1525. unsigned int tag;
  1526. obj_attribute attr;
  1527. } obj_attribute_list;
  1528. /* Object attributes may either be defined by the processor ABI, index
  1529. OBJ_ATTR_PROC in the *_obj_attributes arrays, or be GNU-specific
  1530. (and possibly also processor-specific), index OBJ_ATTR_GNU. */
  1531. #define OBJ_ATTR_PROC 0
  1532. #define OBJ_ATTR_GNU 1
  1533. #define OBJ_ATTR_FIRST OBJ_ATTR_PROC
  1534. #define OBJ_ATTR_LAST OBJ_ATTR_GNU
  1535. /* The following object attribute tags are taken as generic, for all
  1536. targets and for "gnu" where there is no target standard. */
  1537. enum
  1538. {
  1539. Tag_NULL = 0,
  1540. Tag_File = 1,
  1541. Tag_Section = 2,
  1542. Tag_Symbol = 3,
  1543. Tag_compatibility = 32
  1544. };
  1545. /* The following struct stores information about every SystemTap section
  1546. found in the object file. */
  1547. struct sdt_note
  1548. {
  1549. struct sdt_note *next;
  1550. bfd_size_type size;
  1551. bfd_byte data[1];
  1552. };
  1553. /* tdata information grabbed from an elf core file. */
  1554. struct core_elf_obj_tdata
  1555. {
  1556. int signal;
  1557. int pid;
  1558. int lwpid;
  1559. char* program;
  1560. char* command;
  1561. };
  1562. /* Extra tdata information held for output ELF BFDs. */
  1563. struct output_elf_obj_tdata
  1564. {
  1565. struct elf_segment_map *seg_map;
  1566. struct elf_strtab_hash *strtab_ptr;
  1567. /* STT_SECTION symbols for each section */
  1568. asymbol **section_syms;
  1569. /* NT_GNU_BUILD_ID note type info. */
  1570. struct
  1571. {
  1572. bool (*after_write_object_contents) (bfd *);
  1573. const char *style;
  1574. asection *sec;
  1575. } build_id;
  1576. /* Records the result of `get_program_header_size'. */
  1577. bfd_size_type program_header_size;
  1578. /* Used when laying out sections. */
  1579. file_ptr next_file_pos;
  1580. /* Linker information. */
  1581. struct bfd_link_info *link_info;
  1582. unsigned int num_section_syms;
  1583. unsigned int shstrtab_section, strtab_section;
  1584. /* Segment flags for the PT_GNU_STACK segment. */
  1585. unsigned int stack_flags;
  1586. /* Used to determine if the e_flags field has been initialized */
  1587. bool flags_init;
  1588. };
  1589. /* Indicate if the bfd contains SHF_GNU_MBIND/SHF_GNU_RETAIN sections or
  1590. symbols that have the STT_GNU_IFUNC symbol type or STB_GNU_UNIQUE
  1591. binding. Used to set the osabi field in the ELF header structure. */
  1592. enum elf_gnu_osabi
  1593. {
  1594. elf_gnu_osabi_mbind = 1 << 0,
  1595. elf_gnu_osabi_ifunc = 1 << 1,
  1596. elf_gnu_osabi_unique = 1 << 2,
  1597. elf_gnu_osabi_retain = 1 << 3,
  1598. };
  1599. typedef struct elf_section_list
  1600. {
  1601. Elf_Internal_Shdr hdr;
  1602. unsigned int ndx;
  1603. struct elf_section_list * next;
  1604. } elf_section_list;
  1605. enum dynamic_lib_link_class {
  1606. DYN_NORMAL = 0,
  1607. DYN_AS_NEEDED = 1,
  1608. DYN_DT_NEEDED = 2,
  1609. DYN_NO_ADD_NEEDED = 4,
  1610. DYN_NO_NEEDED = 8
  1611. };
  1612. /* Some private data is stashed away for future use using the tdata pointer
  1613. in the bfd structure. */
  1614. struct elf_obj_tdata
  1615. {
  1616. Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
  1617. Elf_Internal_Shdr **elf_sect_ptr;
  1618. Elf_Internal_Phdr *phdr;
  1619. Elf_Internal_Shdr symtab_hdr;
  1620. Elf_Internal_Shdr shstrtab_hdr;
  1621. Elf_Internal_Shdr strtab_hdr;
  1622. Elf_Internal_Shdr dynsymtab_hdr;
  1623. Elf_Internal_Shdr dynstrtab_hdr;
  1624. Elf_Internal_Shdr dynversym_hdr;
  1625. Elf_Internal_Shdr dynverref_hdr;
  1626. Elf_Internal_Shdr dynverdef_hdr;
  1627. elf_section_list * symtab_shndx_list;
  1628. bfd_vma gp; /* The gp value */
  1629. unsigned int gp_size; /* The gp size */
  1630. unsigned int num_elf_sections; /* elf_sect_ptr size */
  1631. unsigned char *being_created;
  1632. /* A mapping from external symbols to entries in the linker hash
  1633. table, used when linking. This is indexed by the symbol index
  1634. minus the sh_info field of the symbol table header. */
  1635. struct elf_link_hash_entry **sym_hashes;
  1636. /* Track usage and final offsets of GOT entries for local symbols.
  1637. This array is indexed by symbol index. Elements are used
  1638. identically to "got" in struct elf_link_hash_entry. */
  1639. union
  1640. {
  1641. bfd_signed_vma *refcounts;
  1642. bfd_vma *offsets;
  1643. struct got_entry **ents;
  1644. } local_got;
  1645. /* The linker ELF emulation code needs to let the backend ELF linker
  1646. know what filename should be used for a dynamic object if the
  1647. dynamic object is found using a search. The emulation code then
  1648. sometimes needs to know what name was actually used. Until the
  1649. file has been added to the linker symbol table, this field holds
  1650. the name the linker wants. After it has been added, it holds the
  1651. name actually used, which will be the DT_SONAME entry if there is
  1652. one. */
  1653. const char *dt_name;
  1654. /* The linker emulation needs to know what audit libs
  1655. are used by a dynamic object. */
  1656. const char *dt_audit;
  1657. /* Used by find_nearest_line entry point. */
  1658. void *line_info;
  1659. /* A place to stash dwarf1 info for this bfd. */
  1660. struct dwarf1_debug *dwarf1_find_line_info;
  1661. /* A place to stash dwarf2 info for this bfd. */
  1662. void *dwarf2_find_line_info;
  1663. /* Stash away info for yet another find line/function variant. */
  1664. void *elf_find_function_cache;
  1665. /* Number of symbol version definitions we are about to emit. */
  1666. unsigned int cverdefs;
  1667. /* Number of symbol version references we are about to emit. */
  1668. unsigned int cverrefs;
  1669. /* Symbol version definitions in external objects. */
  1670. Elf_Internal_Verdef *verdef;
  1671. /* Symbol version references to external objects. */
  1672. Elf_Internal_Verneed *verref;
  1673. /* A pointer to the .eh_frame section. */
  1674. asection *eh_frame_section;
  1675. /* Symbol buffer. */
  1676. void *symbuf;
  1677. /* List of GNU properties. Will be updated by setup_gnu_properties
  1678. after all input GNU properties are merged for output. */
  1679. elf_property_list *properties;
  1680. obj_attribute known_obj_attributes[2][NUM_KNOWN_OBJ_ATTRIBUTES];
  1681. obj_attribute_list *other_obj_attributes[2];
  1682. /* Linked-list containing information about every Systemtap section
  1683. found in the object file. Each section corresponds to one entry
  1684. in the list. */
  1685. struct sdt_note *sdt_note_head;
  1686. Elf_Internal_Shdr **group_sect_ptr;
  1687. unsigned int num_group;
  1688. /* Index into group_sect_ptr, updated by setup_group when finding a
  1689. section's group. Used to optimize subsequent group searches. */
  1690. unsigned int group_search_offset;
  1691. unsigned int symtab_section, dynsymtab_section;
  1692. unsigned int dynversym_section, dynverdef_section, dynverref_section;
  1693. /* An identifier used to distinguish different target
  1694. specific extensions to this structure. */
  1695. ENUM_BITFIELD (elf_target_id) object_id : 6;
  1696. /* Whether a dyanmic object was specified normally on the linker
  1697. command line, or was specified when --as-needed was in effect,
  1698. or was found via a DT_NEEDED entry. */
  1699. ENUM_BITFIELD (dynamic_lib_link_class) dyn_lib_class : 4;
  1700. /* Whether the bfd uses OS specific bits that require ELFOSABI_GNU. */
  1701. ENUM_BITFIELD (elf_gnu_osabi) has_gnu_osabi : 4;
  1702. /* Whether if the bfd contains the GNU_PROPERTY_NO_COPY_ON_PROTECTED
  1703. property. */
  1704. unsigned int has_no_copy_on_protected : 1;
  1705. /* Whether if the bfd contains the
  1706. GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS property. */
  1707. unsigned int has_indirect_extern_access : 1;
  1708. /* Irix 5 often screws up the symbol table, sorting local symbols
  1709. after global symbols. This flag is set if the symbol table in
  1710. this BFD appears to be screwed up. If it is, we ignore the
  1711. sh_info field in the symbol table header, and always read all the
  1712. symbols. */
  1713. unsigned int bad_symtab : 1;
  1714. /* Set if DT_FLAGS_1 has DF_1_PIE set. */
  1715. unsigned int is_pie : 1;
  1716. /* Information grabbed from an elf core file. */
  1717. struct core_elf_obj_tdata *core;
  1718. /* More information held for output ELF BFDs. */
  1719. struct output_elf_obj_tdata *o;
  1720. };
  1721. #define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
  1722. #define elf_object_id(bfd) (elf_tdata(bfd) -> object_id)
  1723. #define elf_program_header_size(bfd) (elf_tdata(bfd) -> o->program_header_size)
  1724. #define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
  1725. #define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
  1726. #define elf_numsections(bfd) (elf_tdata(bfd) -> num_elf_sections)
  1727. #define elf_seg_map(bfd) (elf_tdata(bfd) -> o->seg_map)
  1728. #define elf_link_info(bfd) (elf_tdata(bfd) -> o->link_info)
  1729. #define elf_next_file_pos(bfd) (elf_tdata(bfd) -> o->next_file_pos)
  1730. #define elf_stack_flags(bfd) (elf_tdata(bfd) -> o->stack_flags)
  1731. #define elf_shstrtab(bfd) (elf_tdata(bfd) -> o->strtab_ptr)
  1732. #define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
  1733. #define elf_symtab_shndx_list(bfd) (elf_tdata(bfd) -> symtab_shndx_list)
  1734. #define elf_strtab_sec(bfd) (elf_tdata(bfd) -> o->strtab_section)
  1735. #define elf_shstrtab_sec(bfd) (elf_tdata(bfd) -> o->shstrtab_section)
  1736. #define elf_symtab_hdr(bfd) (elf_tdata(bfd) -> symtab_hdr)
  1737. #define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section)
  1738. #define elf_dynversym(bfd) (elf_tdata(bfd) -> dynversym_section)
  1739. #define elf_dynverdef(bfd) (elf_tdata(bfd) -> dynverdef_section)
  1740. #define elf_dynverref(bfd) (elf_tdata(bfd) -> dynverref_section)
  1741. #define elf_eh_frame_section(bfd) \
  1742. (elf_tdata(bfd) -> eh_frame_section)
  1743. #define elf_section_syms(bfd) (elf_tdata(bfd) -> o->section_syms)
  1744. #define elf_num_section_syms(bfd) (elf_tdata(bfd) -> o->num_section_syms)
  1745. #define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
  1746. #define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
  1747. #define elf_gp(bfd) (elf_tdata(bfd) -> gp)
  1748. #define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size)
  1749. #define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes)
  1750. #define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
  1751. #define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
  1752. #define elf_local_got_ents(bfd) (elf_tdata(bfd) -> local_got.ents)
  1753. #define elf_dt_name(bfd) (elf_tdata(bfd) -> dt_name)
  1754. #define elf_dt_audit(bfd) (elf_tdata(bfd) -> dt_audit)
  1755. #define elf_dyn_lib_class(bfd) (elf_tdata(bfd) -> dyn_lib_class)
  1756. #define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)
  1757. #define elf_flags_init(bfd) (elf_tdata(bfd) -> o->flags_init)
  1758. #define elf_known_obj_attributes(bfd) (elf_tdata (bfd) -> known_obj_attributes)
  1759. #define elf_other_obj_attributes(bfd) (elf_tdata (bfd) -> other_obj_attributes)
  1760. #define elf_known_obj_attributes_proc(bfd) \
  1761. (elf_known_obj_attributes (bfd) [OBJ_ATTR_PROC])
  1762. #define elf_other_obj_attributes_proc(bfd) \
  1763. (elf_other_obj_attributes (bfd) [OBJ_ATTR_PROC])
  1764. #define elf_properties(bfd) (elf_tdata (bfd) -> properties)
  1765. #define elf_has_no_copy_on_protected(bfd) \
  1766. (elf_tdata(bfd) -> has_no_copy_on_protected)
  1767. #define elf_has_indirect_extern_access(bfd) \
  1768. (elf_tdata(bfd) -> has_indirect_extern_access)
  1769. extern void _bfd_elf_swap_verdef_in
  1770. (bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *);
  1771. extern void _bfd_elf_swap_verdef_out
  1772. (bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *);
  1773. extern void _bfd_elf_swap_verdaux_in
  1774. (bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *);
  1775. extern void _bfd_elf_swap_verdaux_out
  1776. (bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *);
  1777. extern void _bfd_elf_swap_verneed_in
  1778. (bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *);
  1779. extern void _bfd_elf_swap_verneed_out
  1780. (bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *);
  1781. extern void _bfd_elf_swap_vernaux_in
  1782. (bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *);
  1783. extern void _bfd_elf_swap_vernaux_out
  1784. (bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *);
  1785. extern void _bfd_elf_swap_versym_in
  1786. (bfd *, const Elf_External_Versym *, Elf_Internal_Versym *);
  1787. extern void _bfd_elf_swap_versym_out
  1788. (bfd *, const Elf_Internal_Versym *, Elf_External_Versym *);
  1789. extern unsigned int _bfd_elf_section_from_bfd_section
  1790. (bfd *, asection *);
  1791. extern char *bfd_elf_string_from_elf_section
  1792. (bfd *, unsigned, unsigned);
  1793. extern Elf_Internal_Sym *bfd_elf_get_elf_syms
  1794. (bfd *, Elf_Internal_Shdr *, size_t, size_t, Elf_Internal_Sym *, void *,
  1795. Elf_External_Sym_Shndx *);
  1796. extern char * bfd_elf_get_str_section (bfd *, unsigned int);
  1797. extern const char *bfd_elf_sym_name
  1798. (bfd *, Elf_Internal_Shdr *, Elf_Internal_Sym *, asection *);
  1799. extern bool _bfd_elf_copy_private_bfd_data
  1800. (bfd *, bfd *);
  1801. extern bool _bfd_elf_print_private_bfd_data
  1802. (bfd *, void *);
  1803. const char * _bfd_elf_get_symbol_version_string
  1804. (bfd *, asymbol *, bool, bool *);
  1805. extern void bfd_elf_print_symbol
  1806. (bfd *, void *, asymbol *, bfd_print_symbol_type);
  1807. extern unsigned int _bfd_elf_eh_frame_address_size
  1808. (bfd *, const asection *);
  1809. extern bfd_byte _bfd_elf_encode_eh_address
  1810. (bfd *abfd, struct bfd_link_info *info, asection *osec, bfd_vma offset,
  1811. asection *loc_sec, bfd_vma loc_offset, bfd_vma *encoded);
  1812. extern bool _bfd_elf_can_make_relative
  1813. (bfd *input_bfd, struct bfd_link_info *info, asection *eh_frame_section);
  1814. extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
  1815. (const struct bfd_link_info *, const asection *,
  1816. const Elf_Internal_Rela *);
  1817. extern bfd_vma _bfd_elf_rela_local_sym
  1818. (bfd *, Elf_Internal_Sym *, asection **, Elf_Internal_Rela *);
  1819. extern bfd_vma _bfd_elf_rel_local_sym
  1820. (bfd *, Elf_Internal_Sym *, asection **, bfd_vma);
  1821. extern bfd_vma _bfd_elf_section_offset
  1822. (bfd *, struct bfd_link_info *, asection *, bfd_vma);
  1823. extern unsigned long bfd_elf_hash
  1824. (const char *);
  1825. extern unsigned long bfd_elf_gnu_hash
  1826. (const char *);
  1827. extern bfd_reloc_status_type bfd_elf_generic_reloc
  1828. (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
  1829. extern bool bfd_elf_allocate_object
  1830. (bfd *, size_t, enum elf_target_id);
  1831. extern bool bfd_elf_make_object
  1832. (bfd *);
  1833. extern bool bfd_elf_mkcorefile
  1834. (bfd *);
  1835. extern bool _bfd_elf_make_section_from_shdr
  1836. (bfd *, Elf_Internal_Shdr *, const char *, int);
  1837. extern bool _bfd_elf_make_section_from_phdr
  1838. (bfd *, Elf_Internal_Phdr *, int, const char *);
  1839. extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
  1840. (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
  1841. extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
  1842. (bfd *);
  1843. extern void _bfd_elf_link_hash_table_free
  1844. (bfd *);
  1845. extern void _bfd_elf_link_hash_copy_indirect
  1846. (struct bfd_link_info *, struct elf_link_hash_entry *,
  1847. struct elf_link_hash_entry *);
  1848. extern void _bfd_elf_link_hash_hide_symbol
  1849. (struct bfd_link_info *, struct elf_link_hash_entry *, bool);
  1850. extern void _bfd_elf_link_hide_symbol
  1851. (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *);
  1852. extern bool _bfd_elf_link_hash_fixup_symbol
  1853. (struct bfd_link_info *, struct elf_link_hash_entry *);
  1854. extern bool _bfd_elf_link_hash_table_init
  1855. (struct elf_link_hash_table *, bfd *,
  1856. struct bfd_hash_entry *(*)
  1857. (struct bfd_hash_entry *, struct bfd_hash_table *, const char *),
  1858. unsigned int, enum elf_target_id);
  1859. extern bool _bfd_elf_slurp_version_tables
  1860. (bfd *, bool);
  1861. extern bool _bfd_elf_merge_sections
  1862. (bfd *, struct bfd_link_info *);
  1863. extern bool _bfd_elf_match_sections_by_type
  1864. (bfd *, const asection *, bfd *, const asection *);
  1865. extern bool bfd_elf_is_group_section
  1866. (bfd *, const struct bfd_section *);
  1867. extern const char *bfd_elf_group_name
  1868. (bfd *, const struct bfd_section *);
  1869. extern bool _bfd_elf_section_already_linked
  1870. (bfd *, asection *, struct bfd_link_info *);
  1871. extern void bfd_elf_set_group_contents
  1872. (bfd *, asection *, void *);
  1873. extern unsigned int _bfd_elf_filter_global_symbols
  1874. (bfd *, struct bfd_link_info *, asymbol **, long);
  1875. extern asection *_bfd_elf_check_kept_section
  1876. (asection *, struct bfd_link_info *);
  1877. #define _bfd_elf_link_just_syms _bfd_generic_link_just_syms
  1878. extern void _bfd_elf_copy_link_hash_symbol_type
  1879. (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *);
  1880. extern bool _bfd_elf_size_group_sections
  1881. (struct bfd_link_info *);
  1882. extern bool _bfd_elf_fixup_group_sections
  1883. (bfd *, asection *);
  1884. extern bool _bfd_elf_copy_private_header_data
  1885. (bfd *, bfd *);
  1886. extern bool _bfd_elf_copy_private_symbol_data
  1887. (bfd *, asymbol *, bfd *, asymbol *);
  1888. #define _bfd_generic_init_private_section_data \
  1889. _bfd_elf_init_private_section_data
  1890. extern bool _bfd_elf_init_private_section_data
  1891. (bfd *, asection *, bfd *, asection *, struct bfd_link_info *);
  1892. extern bool _bfd_elf_copy_private_section_data
  1893. (bfd *, asection *, bfd *, asection *);
  1894. extern bool _bfd_elf_write_object_contents
  1895. (bfd *);
  1896. extern bool _bfd_elf_write_corefile_contents
  1897. (bfd *);
  1898. extern bool _bfd_elf_set_section_contents
  1899. (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type);
  1900. extern long _bfd_elf_get_symtab_upper_bound
  1901. (bfd *);
  1902. extern long _bfd_elf_canonicalize_symtab
  1903. (bfd *, asymbol **);
  1904. extern long _bfd_elf_get_dynamic_symtab_upper_bound
  1905. (bfd *);
  1906. extern long _bfd_elf_canonicalize_dynamic_symtab
  1907. (bfd *, asymbol **);
  1908. extern long _bfd_elf_get_synthetic_symtab
  1909. (bfd *, long, asymbol **, long, asymbol **, asymbol **);
  1910. extern long _bfd_elf_get_reloc_upper_bound
  1911. (bfd *, sec_ptr);
  1912. extern long _bfd_elf_canonicalize_reloc
  1913. (bfd *, sec_ptr, arelent **, asymbol **);
  1914. extern asection * _bfd_elf_get_dynamic_reloc_section
  1915. (bfd *, asection *, bool);
  1916. extern asection * _bfd_elf_make_dynamic_reloc_section
  1917. (asection *, bfd *, unsigned int, bfd *, bool);
  1918. extern long _bfd_elf_get_dynamic_reloc_upper_bound
  1919. (bfd *);
  1920. extern long _bfd_elf_canonicalize_dynamic_reloc
  1921. (bfd *, arelent **, asymbol **);
  1922. extern asymbol *_bfd_elf_make_empty_symbol
  1923. (bfd *);
  1924. extern void _bfd_elf_get_symbol_info
  1925. (bfd *, asymbol *, symbol_info *);
  1926. extern bool _bfd_elf_is_local_label_name
  1927. (bfd *, const char *);
  1928. extern alent *_bfd_elf_get_lineno
  1929. (bfd *, asymbol *);
  1930. extern bool _bfd_elf_set_arch_mach
  1931. (bfd *, enum bfd_architecture, unsigned long);
  1932. extern bool _bfd_elf_find_nearest_line
  1933. (bfd *, asymbol **, asection *, bfd_vma,
  1934. const char **, const char **, unsigned int *, unsigned int *);
  1935. extern bool _bfd_elf_find_line
  1936. (bfd *, asymbol **, asymbol *, const char **, unsigned int *);
  1937. extern bool _bfd_elf_find_inliner_info
  1938. (bfd *, const char **, const char **, unsigned int *);
  1939. extern asymbol *_bfd_elf_find_function
  1940. (bfd *, asymbol **, asection *, bfd_vma, const char **, const char **);
  1941. #define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
  1942. #define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
  1943. extern int _bfd_elf_sizeof_headers
  1944. (bfd *, struct bfd_link_info *);
  1945. extern bool _bfd_elf_new_section_hook
  1946. (bfd *, asection *);
  1947. extern const struct bfd_elf_special_section *_bfd_elf_get_special_section
  1948. (const char *, const struct bfd_elf_special_section *, unsigned int);
  1949. extern const struct bfd_elf_special_section *_bfd_elf_get_sec_type_attr
  1950. (bfd *, asection *);
  1951. extern bool _bfd_elf_link_hide_sym_by_version
  1952. (struct bfd_link_info *, struct elf_link_hash_entry *);
  1953. /* If the target doesn't have reloc handling written yet: */
  1954. extern bool _bfd_elf_no_info_to_howto
  1955. (bfd *, arelent *, Elf_Internal_Rela *);
  1956. extern bool bfd_section_from_shdr
  1957. (bfd *, unsigned int shindex);
  1958. extern bool bfd_section_from_phdr
  1959. (bfd *, Elf_Internal_Phdr *, int);
  1960. extern int _bfd_elf_symbol_from_bfd_symbol
  1961. (bfd *, asymbol **);
  1962. extern Elf_Internal_Sym *bfd_sym_from_r_symndx
  1963. (struct sym_cache *, bfd *, unsigned long);
  1964. extern asection *bfd_section_from_elf_index
  1965. (bfd *, unsigned int);
  1966. extern struct elf_strtab_hash * _bfd_elf_strtab_init
  1967. (void);
  1968. extern void _bfd_elf_strtab_free
  1969. (struct elf_strtab_hash *);
  1970. extern size_t _bfd_elf_strtab_add
  1971. (struct elf_strtab_hash *, const char *, bool);
  1972. extern void _bfd_elf_strtab_addref
  1973. (struct elf_strtab_hash *, size_t);
  1974. extern void _bfd_elf_strtab_delref
  1975. (struct elf_strtab_hash *, size_t);
  1976. extern unsigned int _bfd_elf_strtab_refcount
  1977. (struct elf_strtab_hash *, size_t);
  1978. extern void _bfd_elf_strtab_clear_all_refs
  1979. (struct elf_strtab_hash *);
  1980. extern void *_bfd_elf_strtab_save
  1981. (struct elf_strtab_hash *);
  1982. extern void _bfd_elf_strtab_restore
  1983. (struct elf_strtab_hash *, void *);
  1984. extern bfd_size_type _bfd_elf_strtab_size
  1985. (struct elf_strtab_hash *);
  1986. extern bfd_size_type _bfd_elf_strtab_len
  1987. (struct elf_strtab_hash *);
  1988. extern bfd_size_type _bfd_elf_strtab_offset
  1989. (struct elf_strtab_hash *, size_t);
  1990. extern const char * _bfd_elf_strtab_str
  1991. (struct elf_strtab_hash *, size_t idx, bfd_size_type *offset);
  1992. extern bool _bfd_elf_strtab_emit
  1993. (bfd *, struct elf_strtab_hash *);
  1994. extern void _bfd_elf_strtab_finalize
  1995. (struct elf_strtab_hash *);
  1996. extern bool bfd_elf_parse_eh_frame_entries
  1997. (bfd *, struct bfd_link_info *);
  1998. extern bool _bfd_elf_parse_eh_frame_entry
  1999. (struct bfd_link_info *, asection *, struct elf_reloc_cookie *);
  2000. extern void _bfd_elf_parse_eh_frame
  2001. (bfd *, struct bfd_link_info *, asection *, struct elf_reloc_cookie *);
  2002. extern bool _bfd_elf_end_eh_frame_parsing
  2003. (struct bfd_link_info *info);
  2004. extern bool _bfd_elf_discard_section_eh_frame
  2005. (bfd *, struct bfd_link_info *, asection *,
  2006. bool (*) (bfd_vma, void *), struct elf_reloc_cookie *);
  2007. extern bool _bfd_elf_adjust_eh_frame_global_symbol
  2008. (struct elf_link_hash_entry *, void *);
  2009. extern bool _bfd_elf_discard_section_eh_frame_hdr
  2010. (struct bfd_link_info *);
  2011. extern bfd_vma _bfd_elf_eh_frame_section_offset
  2012. (bfd *, struct bfd_link_info *, asection *, bfd_vma);
  2013. extern bool _bfd_elf_write_section_eh_frame
  2014. (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
  2015. bool _bfd_elf_write_section_eh_frame_entry
  2016. (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
  2017. extern bool _bfd_elf_fixup_eh_frame_hdr (struct bfd_link_info *);
  2018. extern bool _bfd_elf_write_section_eh_frame_hdr
  2019. (bfd *, struct bfd_link_info *);
  2020. extern bool _bfd_elf_eh_frame_present
  2021. (struct bfd_link_info *);
  2022. extern bool _bfd_elf_eh_frame_entry_present
  2023. (struct bfd_link_info *);
  2024. extern bool _bfd_elf_maybe_strip_eh_frame_hdr
  2025. (struct bfd_link_info *);
  2026. extern bool _bfd_elf_hash_symbol (struct elf_link_hash_entry *);
  2027. extern long _bfd_elf_link_lookup_local_dynindx
  2028. (struct bfd_link_info *, bfd *, long);
  2029. extern bool _bfd_elf_compute_section_file_positions
  2030. (bfd *, struct bfd_link_info *);
  2031. extern file_ptr _bfd_elf_assign_file_position_for_section
  2032. (Elf_Internal_Shdr *, file_ptr, bool);
  2033. extern bool _bfd_elf_modify_headers
  2034. (bfd *, struct bfd_link_info *);
  2035. extern bool _bfd_elf_validate_reloc
  2036. (bfd *, arelent *);
  2037. extern bool bfd_elf_record_link_assignment
  2038. (bfd *, struct bfd_link_info *, const char *, bool,
  2039. bool);
  2040. extern bool bfd_elf_stack_segment_size (bfd *, struct bfd_link_info *,
  2041. const char *, bfd_vma);
  2042. extern bool bfd_elf_size_dynamic_sections
  2043. (bfd *, const char *, const char *, const char *, const char *, const char *,
  2044. const char * const *, struct bfd_link_info *, struct bfd_section **);
  2045. extern bool bfd_elf_size_dynsym_hash_dynstr
  2046. (bfd *, struct bfd_link_info *);
  2047. extern bool bfd_elf_get_bfd_needed_list
  2048. (bfd *, struct bfd_link_needed_list **);
  2049. extern struct bfd_link_needed_list *bfd_elf_get_needed_list
  2050. (bfd *, struct bfd_link_info *);
  2051. extern void bfd_elf_set_dt_needed_name
  2052. (bfd *, const char *);
  2053. extern const char *bfd_elf_get_dt_soname
  2054. (bfd *);
  2055. extern void bfd_elf_set_dyn_lib_class
  2056. (bfd *, enum dynamic_lib_link_class);
  2057. extern int bfd_elf_get_dyn_lib_class
  2058. (bfd *);
  2059. extern struct bfd_link_needed_list *bfd_elf_get_runpath_list
  2060. (bfd *, struct bfd_link_info *);
  2061. extern int bfd_elf_discard_info
  2062. (bfd *, struct bfd_link_info *);
  2063. extern unsigned int _bfd_elf_default_action_discarded
  2064. (struct bfd_section *);
  2065. extern struct bfd_section *_bfd_elf_tls_setup
  2066. (bfd *, struct bfd_link_info *);
  2067. extern bool _bfd_elf_link_create_dynamic_sections
  2068. (bfd *, struct bfd_link_info *);
  2069. extern bool _bfd_elf_omit_section_dynsym_default
  2070. (bfd *, struct bfd_link_info *, asection *);
  2071. extern bool _bfd_elf_omit_section_dynsym_all
  2072. (bfd *, struct bfd_link_info *, asection *);
  2073. extern bool _bfd_elf_create_dynamic_sections
  2074. (bfd *, struct bfd_link_info *);
  2075. extern bool _bfd_elf_create_got_section
  2076. (bfd *, struct bfd_link_info *);
  2077. extern asection *_bfd_elf_section_for_symbol
  2078. (struct elf_reloc_cookie *, unsigned long, bool);
  2079. extern struct elf_link_hash_entry *_bfd_elf_define_linkage_sym
  2080. (bfd *, struct bfd_link_info *, asection *, const char *);
  2081. extern void _bfd_elf_init_1_index_section
  2082. (bfd *, struct bfd_link_info *);
  2083. extern void _bfd_elf_init_2_index_sections
  2084. (bfd *, struct bfd_link_info *);
  2085. extern bool _bfd_elfcore_make_pseudosection
  2086. (bfd *, char *, size_t, ufile_ptr);
  2087. extern char *_bfd_elfcore_strndup
  2088. (bfd *, char *, size_t);
  2089. extern Elf_Internal_Rela *_bfd_elf_link_read_relocs
  2090. (bfd *, asection *, void *, Elf_Internal_Rela *, bool);
  2091. extern Elf_Internal_Rela *_bfd_elf_link_info_read_relocs
  2092. (bfd *, struct bfd_link_info *, asection *, void *, Elf_Internal_Rela *,
  2093. bool);
  2094. extern bool _bfd_elf_link_output_relocs
  2095. (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *,
  2096. struct elf_link_hash_entry **);
  2097. extern bool _bfd_elf_adjust_dynamic_copy
  2098. (struct bfd_link_info *, struct elf_link_hash_entry *, asection *);
  2099. extern bool _bfd_elf_dynamic_symbol_p
  2100. (struct elf_link_hash_entry *, struct bfd_link_info *, bool);
  2101. extern bool _bfd_elf_symbol_refs_local_p
  2102. (struct elf_link_hash_entry *, struct bfd_link_info *, bool);
  2103. extern bfd_reloc_status_type bfd_elf_perform_complex_relocation
  2104. (bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, bfd_vma);
  2105. extern bool _bfd_elf_setup_sections
  2106. (bfd *);
  2107. extern struct bfd_link_hash_entry *bfd_elf_define_start_stop
  2108. (struct bfd_link_info *, const char *, asection *);
  2109. extern bool _bfd_elf_init_file_header (bfd *, struct bfd_link_info *);
  2110. extern bool _bfd_elf_final_write_processing (bfd *);
  2111. extern bfd_cleanup bfd_elf32_object_p
  2112. (bfd *);
  2113. extern bfd_cleanup bfd_elf32_core_file_p
  2114. (bfd *);
  2115. extern char *bfd_elf32_core_file_failing_command
  2116. (bfd *);
  2117. extern int bfd_elf32_core_file_failing_signal
  2118. (bfd *);
  2119. extern bool bfd_elf32_core_file_matches_executable_p
  2120. (bfd *, bfd *);
  2121. extern int bfd_elf32_core_file_pid
  2122. (bfd *);
  2123. extern bool _bfd_elf32_core_find_build_id
  2124. (bfd *, bfd_vma);
  2125. extern bool bfd_elf32_swap_symbol_in
  2126. (bfd *, const void *, const void *, Elf_Internal_Sym *);
  2127. extern void bfd_elf32_swap_symbol_out
  2128. (bfd *, const Elf_Internal_Sym *, void *, void *);
  2129. extern void bfd_elf32_swap_reloc_in
  2130. (bfd *, const bfd_byte *, Elf_Internal_Rela *);
  2131. extern void bfd_elf32_swap_reloc_out
  2132. (bfd *, const Elf_Internal_Rela *, bfd_byte *);
  2133. extern void bfd_elf32_swap_reloca_in
  2134. (bfd *, const bfd_byte *, Elf_Internal_Rela *);
  2135. extern void bfd_elf32_swap_reloca_out
  2136. (bfd *, const Elf_Internal_Rela *, bfd_byte *);
  2137. extern void bfd_elf32_swap_phdr_in
  2138. (bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *);
  2139. extern void bfd_elf32_swap_phdr_out
  2140. (bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *);
  2141. extern void bfd_elf32_swap_dyn_in
  2142. (bfd *, const void *, Elf_Internal_Dyn *);
  2143. extern void bfd_elf32_swap_dyn_out
  2144. (bfd *, const Elf_Internal_Dyn *, void *);
  2145. extern long bfd_elf32_slurp_symbol_table
  2146. (bfd *, asymbol **, bool);
  2147. extern bool bfd_elf32_write_shdrs_and_ehdr
  2148. (bfd *);
  2149. extern int bfd_elf32_write_out_phdrs
  2150. (bfd *, const Elf_Internal_Phdr *, unsigned int);
  2151. extern bool bfd_elf32_checksum_contents
  2152. (bfd * , void (*) (const void *, size_t, void *), void *);
  2153. extern void bfd_elf32_write_relocs
  2154. (bfd *, asection *, void *);
  2155. extern bool bfd_elf32_slurp_reloc_table
  2156. (bfd *, asection *, asymbol **, bool);
  2157. extern bfd_cleanup bfd_elf64_object_p
  2158. (bfd *);
  2159. extern bfd_cleanup bfd_elf64_core_file_p
  2160. (bfd *);
  2161. extern char *bfd_elf64_core_file_failing_command
  2162. (bfd *);
  2163. extern int bfd_elf64_core_file_failing_signal
  2164. (bfd *);
  2165. extern bool bfd_elf64_core_file_matches_executable_p
  2166. (bfd *, bfd *);
  2167. extern int bfd_elf64_core_file_pid
  2168. (bfd *);
  2169. extern bool _bfd_elf64_core_find_build_id
  2170. (bfd *, bfd_vma);
  2171. extern bool bfd_elf64_swap_symbol_in
  2172. (bfd *, const void *, const void *, Elf_Internal_Sym *);
  2173. extern void bfd_elf64_swap_symbol_out
  2174. (bfd *, const Elf_Internal_Sym *, void *, void *);
  2175. extern void bfd_elf64_swap_reloc_in
  2176. (bfd *, const bfd_byte *, Elf_Internal_Rela *);
  2177. extern void bfd_elf64_swap_reloc_out
  2178. (bfd *, const Elf_Internal_Rela *, bfd_byte *);
  2179. extern void bfd_elf64_swap_reloca_in
  2180. (bfd *, const bfd_byte *, Elf_Internal_Rela *);
  2181. extern void bfd_elf64_swap_reloca_out
  2182. (bfd *, const Elf_Internal_Rela *, bfd_byte *);
  2183. extern void bfd_elf64_swap_phdr_in
  2184. (bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *);
  2185. extern void bfd_elf64_swap_phdr_out
  2186. (bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *);
  2187. extern void bfd_elf64_swap_dyn_in
  2188. (bfd *, const void *, Elf_Internal_Dyn *);
  2189. extern void bfd_elf64_swap_dyn_out
  2190. (bfd *, const Elf_Internal_Dyn *, void *);
  2191. extern long bfd_elf64_slurp_symbol_table
  2192. (bfd *, asymbol **, bool);
  2193. extern bool bfd_elf64_write_shdrs_and_ehdr
  2194. (bfd *);
  2195. extern int bfd_elf64_write_out_phdrs
  2196. (bfd *, const Elf_Internal_Phdr *, unsigned int);
  2197. extern bool bfd_elf64_checksum_contents
  2198. (bfd * , void (*) (const void *, size_t, void *), void *);
  2199. extern void bfd_elf64_write_relocs
  2200. (bfd *, asection *, void *);
  2201. extern bool bfd_elf64_slurp_reloc_table
  2202. (bfd *, asection *, asymbol **, bool);
  2203. extern bool _bfd_elf_default_relocs_compatible
  2204. (const bfd_target *, const bfd_target *);
  2205. extern bool _bfd_elf_relocs_compatible
  2206. (const bfd_target *, const bfd_target *);
  2207. extern bool _bfd_elf_notice_as_needed
  2208. (bfd *, struct bfd_link_info *, enum notice_asneeded_action);
  2209. extern struct bfd_link_hash_entry *_bfd_elf_archive_symbol_lookup
  2210. (bfd *, struct bfd_link_info *, const char *);
  2211. extern bool bfd_elf_link_add_symbols
  2212. (bfd *, struct bfd_link_info *);
  2213. extern bool _bfd_elf_add_dynamic_entry
  2214. (struct bfd_link_info *, bfd_vma, bfd_vma);
  2215. extern bool _bfd_elf_strip_zero_sized_dynamic_sections
  2216. (struct bfd_link_info *);
  2217. extern int bfd_elf_add_dt_needed_tag
  2218. (bfd *, struct bfd_link_info *);
  2219. extern bool _bfd_elf_link_check_relocs
  2220. (bfd *, struct bfd_link_info *);
  2221. extern bool _bfd_elf_link_iterate_on_relocs
  2222. (bfd *, struct bfd_link_info *,
  2223. bool (*) (bfd *, struct bfd_link_info *, asection *,
  2224. const Elf_Internal_Rela *));
  2225. extern bool bfd_elf_link_record_dynamic_symbol
  2226. (struct bfd_link_info *, struct elf_link_hash_entry *);
  2227. extern int bfd_elf_link_record_local_dynamic_symbol
  2228. (struct bfd_link_info *, bfd *, long);
  2229. extern bool _bfd_elf_close_and_cleanup
  2230. (bfd *);
  2231. extern bool _bfd_elf_common_definition
  2232. (Elf_Internal_Sym *);
  2233. extern unsigned int _bfd_elf_common_section_index
  2234. (asection *);
  2235. extern asection *_bfd_elf_common_section
  2236. (asection *);
  2237. extern bfd_vma _bfd_elf_default_got_elt_size
  2238. (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, bfd *,
  2239. unsigned long);
  2240. extern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
  2241. (bfd *, arelent *, struct bfd_symbol *, void *,
  2242. asection *, bfd *, char **);
  2243. extern bool bfd_elf_final_link
  2244. (bfd *, struct bfd_link_info *);
  2245. extern void _bfd_elf_gc_keep
  2246. (struct bfd_link_info *info);
  2247. extern bool bfd_elf_gc_mark_dynamic_ref_symbol
  2248. (struct elf_link_hash_entry *h, void *inf);
  2249. extern bool bfd_elf_gc_sections
  2250. (bfd *, struct bfd_link_info *);
  2251. extern bool bfd_elf_gc_record_vtinherit
  2252. (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma);
  2253. extern bool bfd_elf_gc_record_vtentry
  2254. (bfd *, asection *, struct elf_link_hash_entry *, bfd_vma);
  2255. extern asection *_bfd_elf_gc_mark_hook
  2256. (asection *, struct bfd_link_info *, Elf_Internal_Rela *,
  2257. struct elf_link_hash_entry *, Elf_Internal_Sym *);
  2258. extern asection *_bfd_elf_gc_mark_rsec
  2259. (struct bfd_link_info *, asection *, elf_gc_mark_hook_fn,
  2260. struct elf_reloc_cookie *, bool *);
  2261. extern bool _bfd_elf_gc_mark_reloc
  2262. (struct bfd_link_info *, asection *, elf_gc_mark_hook_fn,
  2263. struct elf_reloc_cookie *);
  2264. extern bool _bfd_elf_gc_mark_fdes
  2265. (struct bfd_link_info *, asection *, asection *, elf_gc_mark_hook_fn,
  2266. struct elf_reloc_cookie *);
  2267. extern bool _bfd_elf_gc_mark
  2268. (struct bfd_link_info *, asection *, elf_gc_mark_hook_fn);
  2269. extern bool _bfd_elf_gc_mark_extra_sections
  2270. (struct bfd_link_info *, elf_gc_mark_hook_fn);
  2271. extern bool bfd_elf_gc_common_finalize_got_offsets
  2272. (bfd *, struct bfd_link_info *);
  2273. extern bool bfd_elf_gc_common_final_link
  2274. (bfd *, struct bfd_link_info *);
  2275. extern bool bfd_elf_reloc_symbol_deleted_p
  2276. (bfd_vma, void *);
  2277. extern struct elf_segment_map * _bfd_elf_make_dynamic_segment
  2278. (bfd *, asection *);
  2279. extern bool _bfd_elf_map_sections_to_segments
  2280. (bfd *, struct bfd_link_info *, bool *);
  2281. extern bool _bfd_elf_is_function_type (unsigned int);
  2282. extern bfd_size_type _bfd_elf_maybe_function_sym (const asymbol *, asection *,
  2283. bfd_vma *);
  2284. extern asection *_bfd_elf_plt_get_reloc_section (bfd *, const char *);
  2285. extern int bfd_elf_get_default_section_type (flagword);
  2286. extern bool bfd_elf_lookup_section_flags
  2287. (struct bfd_link_info *, struct flag_info *, asection *);
  2288. extern Elf_Internal_Phdr * _bfd_elf_find_segment_containing_section
  2289. (bfd * abfd, asection * section);
  2290. /* PowerPC @tls opcode transform/validate. */
  2291. extern unsigned int _bfd_elf_ppc_at_tls_transform
  2292. (unsigned int, unsigned int);
  2293. /* PowerPC @tprel opcode transform/validate. */
  2294. extern unsigned int _bfd_elf_ppc_at_tprel_transform
  2295. (unsigned int, unsigned int);
  2296. /* PowerPC elf_object_p tweak. */
  2297. extern bool _bfd_elf_ppc_set_arch (bfd *);
  2298. /* PowerPC .gnu.attributes handling common to both 32-bit and 64-bit. */
  2299. extern bool _bfd_elf_ppc_merge_fp_attributes
  2300. (bfd *, struct bfd_link_info *);
  2301. /* Return an upper bound on the number of bytes required to store a
  2302. copy of ABFD's program header table entries. Return -1 if an error
  2303. occurs; bfd_get_error will return an appropriate code. */
  2304. extern long bfd_get_elf_phdr_upper_bound
  2305. (bfd *abfd);
  2306. /* Copy ABFD's program header table entries to *PHDRS. The entries
  2307. will be stored as an array of Elf_Internal_Phdr structures, as
  2308. defined in include/elf/internal.h. To find out how large the
  2309. buffer needs to be, call bfd_get_elf_phdr_upper_bound.
  2310. Return the number of program header table entries read, or -1 if an
  2311. error occurs; bfd_get_error will return an appropriate code. */
  2312. extern int bfd_get_elf_phdrs
  2313. (bfd *abfd, void *phdrs);
  2314. /* Exported interface for writing elf corefile notes. */
  2315. extern char *elfcore_write_note
  2316. (bfd *, char *, int *, const char *, int, const void *, int);
  2317. extern char *elfcore_write_prpsinfo
  2318. (bfd *, char *, int *, const char *, const char *);
  2319. extern char *elfcore_write_prstatus
  2320. (bfd *, char *, int *, long, int, const void *);
  2321. extern char * elfcore_write_pstatus
  2322. (bfd *, char *, int *, long, int, const void *);
  2323. extern char *elfcore_write_prfpreg
  2324. (bfd *, char *, int *, const void *, int);
  2325. extern char *elfcore_write_prxfpreg
  2326. (bfd *, char *, int *, const void *, int);
  2327. extern char *elfcore_write_xstatereg
  2328. (bfd *, char *, int *, const void *, int);
  2329. extern char *elfcore_write_x86_segbases
  2330. (bfd *, char *, int *, const void *, int);
  2331. extern char *elfcore_write_ppc_vmx
  2332. (bfd *, char *, int *, const void *, int);
  2333. extern char *elfcore_write_ppc_vsx
  2334. (bfd *, char *, int *, const void *, int);
  2335. extern char *elfcore_write_ppc_tar
  2336. (bfd *, char *, int *, const void *, int);
  2337. extern char *elfcore_write_ppc_ppr
  2338. (bfd *, char *, int *, const void *, int);
  2339. extern char *elfcore_write_ppc_dscr
  2340. (bfd *, char *, int *, const void *, int);
  2341. extern char *elfcore_write_ppc_ebb
  2342. (bfd *, char *, int *, const void *, int);
  2343. extern char *elfcore_write_ppc_pmu
  2344. (bfd *, char *, int *, const void *, int);
  2345. extern char *elfcore_write_ppc_tm_cgpr
  2346. (bfd *, char *, int *, const void *, int);
  2347. extern char *elfcore_write_ppc_tm_cfpr
  2348. (bfd *, char *, int *, const void *, int);
  2349. extern char *elfcore_write_ppc_tm_cvmx
  2350. (bfd *, char *, int *, const void *, int);
  2351. extern char *elfcore_write_ppc_tm_cvsx
  2352. (bfd *, char *, int *, const void *, int);
  2353. extern char *elfcore_write_ppc_tm_spr
  2354. (bfd *, char *, int *, const void *, int);
  2355. extern char *elfcore_write_ppc_tm_ctar
  2356. (bfd *, char *, int *, const void *, int);
  2357. extern char *elfcore_write_ppc_tm_cppr
  2358. (bfd *, char *, int *, const void *, int);
  2359. extern char *elfcore_write_ppc_tm_cdscr
  2360. (bfd *, char *, int *, const void *, int);
  2361. extern char *elfcore_write_s390_timer
  2362. (bfd *, char *, int *, const void *, int);
  2363. extern char *elfcore_write_s390_todcmp
  2364. (bfd *, char *, int *, const void *, int);
  2365. extern char *elfcore_write_s390_todpreg
  2366. (bfd *, char *, int *, const void *, int);
  2367. extern char *elfcore_write_s390_ctrs
  2368. (bfd *, char *, int *, const void *, int);
  2369. extern char *elfcore_write_s390_prefix
  2370. (bfd *, char *, int *, const void *, int);
  2371. extern char *elfcore_write_s390_last_break
  2372. (bfd *, char *, int *, const void *, int);
  2373. extern char *elfcore_write_s390_system_call
  2374. (bfd *, char *, int *, const void *, int);
  2375. extern char *elfcore_write_s390_tdb
  2376. (bfd *, char *, int *, const void *, int);
  2377. extern char *elfcore_write_s390_vxrs_low
  2378. (bfd *, char *, int *, const void *, int);
  2379. extern char *elfcore_write_s390_vxrs_high
  2380. (bfd *, char *, int *, const void *, int);
  2381. extern char *elfcore_write_s390_gs_cb
  2382. (bfd *, char *, int *, const void *, int);
  2383. extern char *elfcore_write_s390_gs_bc
  2384. (bfd *, char *, int *, const void *, int);
  2385. extern char *elfcore_write_arm_vfp
  2386. (bfd *, char *, int *, const void *, int);
  2387. extern char *elfcore_write_aarch_tls
  2388. (bfd *, char *, int *, const void *, int);
  2389. extern char *elfcore_write_aarch_hw_break
  2390. (bfd *, char *, int *, const void *, int);
  2391. extern char *elfcore_write_aarch_hw_watch
  2392. (bfd *, char *, int *, const void *, int);
  2393. extern char *elfcore_write_aarch_sve
  2394. (bfd *, char *, int *, const void *, int);
  2395. extern char *elfcore_write_aarch_pauth
  2396. (bfd *, char *, int *, const void *, int);
  2397. extern char *elfcore_write_aarch_mte
  2398. (bfd *, char *, int *, const void *, int);
  2399. extern char *elfcore_write_arc_v2
  2400. (bfd *, char *, int *, const void *, int);
  2401. extern char *elfcore_write_riscv_csr
  2402. (bfd *, char *, int *, const void *, int);
  2403. extern char *elfcore_write_gdb_tdesc
  2404. (bfd *, char *, int *, const void *, int);
  2405. extern char *elfcore_write_lwpstatus
  2406. (bfd *, char *, int *, long, int, const void *);
  2407. extern char *elfcore_write_register_note
  2408. (bfd *, char *, int *, const char *, const void *, int);
  2409. extern char *elfcore_write_file_note
  2410. (bfd *, char *, int *, const void*, int);
  2411. extern char *elfcore_write_loongarch_cpucfg
  2412. (bfd *, char *, int *, const void*, int);
  2413. extern char *elfcore_write_loongarch_lbt
  2414. (bfd *, char *, int *, const void*, int);
  2415. extern char *elfcore_write_loongarch_lsx
  2416. (bfd *, char *, int *, const void*, int);
  2417. extern char *elfcore_write_loongarch_lasx
  2418. (bfd *, char *, int *, const void*, int);
  2419. /* Internal structure which holds information to be included in the
  2420. PRPSINFO section of Linux core files.
  2421. This is an "internal" structure in the sense that it should be used
  2422. to pass information to BFD (via the `elfcore_write_linux_prpsinfo'
  2423. function), so things like endianess shouldn't be an issue. This
  2424. structure will eventually be converted in one of the
  2425. `elf_external_linux_*' structures and written out to an output bfd
  2426. by one of the functions declared below. */
  2427. struct elf_internal_linux_prpsinfo
  2428. {
  2429. char pr_state; /* Numeric process state. */
  2430. char pr_sname; /* Char for pr_state. */
  2431. char pr_zomb; /* Zombie. */
  2432. char pr_nice; /* Nice val. */
  2433. unsigned long pr_flag; /* Flags. */
  2434. unsigned int pr_uid;
  2435. unsigned int pr_gid;
  2436. int pr_pid, pr_ppid, pr_pgrp, pr_sid;
  2437. char pr_fname[16 + 1]; /* Filename of executable. */
  2438. char pr_psargs[80 + 1]; /* Initial part of arg list. */
  2439. };
  2440. /* Linux/most 32-bit archs. */
  2441. extern char *elfcore_write_linux_prpsinfo32
  2442. (bfd *, char *, int *, const struct elf_internal_linux_prpsinfo *);
  2443. /* Linux/most 64-bit archs. */
  2444. extern char *elfcore_write_linux_prpsinfo64
  2445. (bfd *, char *, int *, const struct elf_internal_linux_prpsinfo *);
  2446. extern bfd *_bfd_elf32_bfd_from_remote_memory
  2447. (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
  2448. int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type));
  2449. extern bfd *_bfd_elf64_bfd_from_remote_memory
  2450. (bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep,
  2451. int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type));
  2452. extern bfd_vma bfd_elf_obj_attr_size (bfd *);
  2453. extern void bfd_elf_set_obj_attr_contents (bfd *, bfd_byte *, bfd_vma);
  2454. extern int bfd_elf_get_obj_attr_int (bfd *, int, unsigned int);
  2455. extern void bfd_elf_add_obj_attr_int (bfd *, int, unsigned int, unsigned int);
  2456. #define bfd_elf_add_proc_attr_int(BFD, TAG, VALUE) \
  2457. bfd_elf_add_obj_attr_int ((BFD), OBJ_ATTR_PROC, (TAG), (VALUE))
  2458. extern void bfd_elf_add_obj_attr_string (bfd *, int, unsigned int, const char *);
  2459. #define bfd_elf_add_proc_attr_string(BFD, TAG, VALUE) \
  2460. bfd_elf_add_obj_attr_string ((BFD), OBJ_ATTR_PROC, (TAG), (VALUE))
  2461. extern void bfd_elf_add_obj_attr_int_string (bfd *, int, unsigned int,
  2462. unsigned int, const char *);
  2463. #define bfd_elf_add_proc_attr_int_string(BFD, TAG, INTVAL, STRVAL) \
  2464. bfd_elf_add_obj_attr_int_string ((BFD), OBJ_ATTR_PROC, (TAG), \
  2465. (INTVAL), (STRVAL))
  2466. extern char *_bfd_elf_attr_strdup (bfd *, const char *);
  2467. extern void _bfd_elf_copy_obj_attributes (bfd *, bfd *);
  2468. extern int _bfd_elf_obj_attrs_arg_type (bfd *, int, unsigned int);
  2469. extern void _bfd_elf_parse_attributes (bfd *, Elf_Internal_Shdr *);
  2470. extern bool _bfd_elf_merge_object_attributes
  2471. (bfd *, struct bfd_link_info *);
  2472. extern bool _bfd_elf_merge_unknown_attribute_low (bfd *, bfd *, int);
  2473. extern bool _bfd_elf_merge_unknown_attribute_list (bfd *, bfd *);
  2474. extern Elf_Internal_Shdr *_bfd_elf_single_rel_hdr (asection *sec);
  2475. extern bool elf_read_notes (bfd *, file_ptr, bfd_size_type, size_t);
  2476. extern bool _bfd_elf_parse_gnu_properties
  2477. (bfd *, Elf_Internal_Note *);
  2478. extern elf_property * _bfd_elf_get_property
  2479. (bfd *, unsigned int, unsigned int);
  2480. extern bfd *_bfd_elf_link_setup_gnu_properties
  2481. (struct bfd_link_info *);
  2482. extern bfd_size_type _bfd_elf_convert_gnu_property_size
  2483. (bfd *, bfd *);
  2484. extern bool _bfd_elf_convert_gnu_properties
  2485. (bfd *, asection *, bfd *, bfd_byte **, bfd_size_type *);
  2486. /* The linker may need to keep track of the number of relocs that it
  2487. decides to copy as dynamic relocs in check_relocs for each symbol.
  2488. This is so that it can later discard them if they are found to be
  2489. unnecessary. We can store the information in a field extending the
  2490. regular ELF linker hash table. */
  2491. struct elf_dyn_relocs
  2492. {
  2493. struct elf_dyn_relocs *next;
  2494. /* The input section of the reloc. */
  2495. asection *sec;
  2496. /* Total number of relocs copied for the input section. */
  2497. bfd_size_type count;
  2498. /* Number of pc-relative relocs copied for the input section. */
  2499. bfd_size_type pc_count;
  2500. };
  2501. extern bool _bfd_elf_create_ifunc_sections
  2502. (bfd *, struct bfd_link_info *);
  2503. extern bool _bfd_elf_allocate_ifunc_dyn_relocs
  2504. (struct bfd_link_info *, struct elf_link_hash_entry *,
  2505. struct elf_dyn_relocs **, unsigned int, unsigned int,
  2506. unsigned int, bool);
  2507. extern void elf_append_rela (bfd *, asection *, Elf_Internal_Rela *);
  2508. extern void elf_append_rel (bfd *, asection *, Elf_Internal_Rela *);
  2509. extern bfd_vma elf64_r_info (bfd_vma, bfd_vma);
  2510. extern bfd_vma elf64_r_sym (bfd_vma);
  2511. extern bfd_vma elf32_r_info (bfd_vma, bfd_vma);
  2512. extern bfd_vma elf32_r_sym (bfd_vma);
  2513. extern bool is_debuginfo_file (bfd *);
  2514. extern bool _bfd_elf_init_secondary_reloc_section
  2515. (bfd *, Elf_Internal_Shdr *, const char *, unsigned int);
  2516. extern bool _bfd_elf_slurp_secondary_reloc_section
  2517. (bfd *, asection *, asymbol **, bool);
  2518. extern bool _bfd_elf_copy_special_section_fields
  2519. (const bfd *, bfd *, const Elf_Internal_Shdr *, Elf_Internal_Shdr *);
  2520. extern bool _bfd_elf_write_secondary_reloc_section
  2521. (bfd *, asection *);
  2522. extern unsigned int _bfd_elf_symbol_section_index
  2523. (bfd *, elf_symbol_type *);
  2524. extern asection *_bfd_elf_readonly_dynrelocs
  2525. (struct elf_link_hash_entry *);
  2526. extern bool _bfd_elf_maybe_set_textrel
  2527. (struct elf_link_hash_entry *, void *);
  2528. extern bool _bfd_elf_add_dynamic_tags
  2529. (bfd *, struct bfd_link_info *, bool);
  2530. /* Large common section. */
  2531. extern asection _bfd_elf_large_com_section;
  2532. /* Hash for local symbol with the first section id, ID, in the input
  2533. file and the local symbol index, SYM. */
  2534. #define ELF_LOCAL_SYMBOL_HASH(ID, SYM) \
  2535. (((((ID) & 0xffU) << 24) | (((ID) & 0xff00) << 8)) \
  2536. ^ (SYM) ^ (((ID) & 0xffff0000U) >> 16))
  2537. /* This is the condition under which finish_dynamic_symbol will be called.
  2538. If our finish_dynamic_symbol isn't called, we'll need to do something
  2539. about initializing any .plt and .got entries in relocate_section. */
  2540. #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H) \
  2541. ((DYN) \
  2542. && ((SHARED) || !(H)->forced_local) \
  2543. && ((H)->dynindx != -1 || (H)->forced_local))
  2544. /* This macro is to avoid lots of duplicated code in the body
  2545. of xxx_relocate_section() in the various elfxx-xxxx.c files. */
  2546. #define RELOC_FOR_GLOBAL_SYMBOL(info, input_bfd, input_section, rel, \
  2547. r_symndx, symtab_hdr, sym_hashes, \
  2548. h, sec, relocation, \
  2549. unresolved_reloc, warned, ignored) \
  2550. do \
  2551. { \
  2552. /* It seems this can happen with erroneous or unsupported \
  2553. input (mixing a.out and elf in an archive, for example.) */ \
  2554. if (sym_hashes == NULL) \
  2555. return false; \
  2556. \
  2557. h = sym_hashes[r_symndx - symtab_hdr->sh_info]; \
  2558. \
  2559. if (info->wrap_hash != NULL \
  2560. && (input_section->flags & SEC_DEBUGGING) != 0) \
  2561. h = ((struct elf_link_hash_entry *) \
  2562. unwrap_hash_lookup (info, input_bfd, &h->root)); \
  2563. \
  2564. while (h->root.type == bfd_link_hash_indirect \
  2565. || h->root.type == bfd_link_hash_warning) \
  2566. h = (struct elf_link_hash_entry *) h->root.u.i.link; \
  2567. \
  2568. warned = false; \
  2569. ignored = false; \
  2570. unresolved_reloc = false; \
  2571. relocation = 0; \
  2572. if (h->root.type == bfd_link_hash_defined \
  2573. || h->root.type == bfd_link_hash_defweak) \
  2574. { \
  2575. sec = h->root.u.def.section; \
  2576. if (sec == NULL \
  2577. || sec->output_section == NULL) \
  2578. /* Set a flag that will be cleared later if we find a \
  2579. relocation value for this symbol. output_section \
  2580. is typically NULL for symbols satisfied by a shared \
  2581. library. */ \
  2582. unresolved_reloc = true; \
  2583. else \
  2584. relocation = (h->root.u.def.value \
  2585. + sec->output_section->vma \
  2586. + sec->output_offset); \
  2587. } \
  2588. else if (h->root.type == bfd_link_hash_undefweak) \
  2589. ; \
  2590. else if (info->unresolved_syms_in_objects == RM_IGNORE \
  2591. && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) \
  2592. ignored = true; \
  2593. else if (!bfd_link_relocatable (info)) \
  2594. { \
  2595. bool err = ((info->unresolved_syms_in_objects == RM_DIAGNOSE \
  2596. && !info->warn_unresolved_syms) \
  2597. || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT); \
  2598. (*info->callbacks->undefined_symbol) (info, \
  2599. h->root.root.string, \
  2600. input_bfd, \
  2601. input_section, \
  2602. rel->r_offset, err); \
  2603. warned = true; \
  2604. } \
  2605. (void) unresolved_reloc; \
  2606. (void) warned; \
  2607. (void) ignored; \
  2608. } \
  2609. while (0)
  2610. /* This macro is to avoid lots of duplicated code in the body of the
  2611. loop over relocations in xxx_relocate_section() in the various
  2612. elfxx-xxxx.c files.
  2613. Handle relocations against symbols from removed linkonce sections,
  2614. or sections discarded by a linker script. When doing a relocatable
  2615. link, we remove such relocations. Otherwise, we just want the
  2616. section contents zeroed and avoid any special processing. */
  2617. #define RELOC_AGAINST_DISCARDED_SECTION(info, input_bfd, input_section, \
  2618. rel, count, relend, \
  2619. howto, index, contents) \
  2620. { \
  2621. int i_; \
  2622. _bfd_clear_contents (howto, input_bfd, input_section, \
  2623. contents, rel[index].r_offset); \
  2624. \
  2625. if (bfd_link_relocatable (info) \
  2626. && (input_section->flags & SEC_DEBUGGING)) \
  2627. { \
  2628. /* Only remove relocations in debug sections since other \
  2629. sections may require relocations. */ \
  2630. Elf_Internal_Shdr *rel_hdr; \
  2631. \
  2632. rel_hdr = _bfd_elf_single_rel_hdr (input_section->output_section); \
  2633. \
  2634. /* Avoid empty output section. */ \
  2635. if (rel_hdr->sh_size > rel_hdr->sh_entsize) \
  2636. { \
  2637. rel_hdr->sh_size -= rel_hdr->sh_entsize; \
  2638. rel_hdr = _bfd_elf_single_rel_hdr (input_section); \
  2639. rel_hdr->sh_size -= rel_hdr->sh_entsize; \
  2640. \
  2641. memmove (rel, rel + count, \
  2642. (relend - rel - count) * sizeof (*rel)); \
  2643. \
  2644. input_section->reloc_count -= count; \
  2645. relend -= count; \
  2646. rel--; \
  2647. continue; \
  2648. } \
  2649. } \
  2650. \
  2651. for (i_ = 0; i_ < count; i_++) \
  2652. { \
  2653. rel[i_].r_info = 0; \
  2654. rel[i_].r_addend = 0; \
  2655. } \
  2656. rel += count - 1; \
  2657. continue; \
  2658. }
  2659. /* Will a symbol be bound to the definition within the shared
  2660. library, if any. A unique symbol can never be bound locally. */
  2661. #define SYMBOLIC_BIND(INFO, H) \
  2662. (!(H)->unique_global \
  2663. && ((INFO)->symbolic \
  2664. || (H)->start_stop \
  2665. || ((INFO)->dynamic && !(H)->dynamic)))
  2666. /* Determine if a section contains CTF data, using its name. */
  2667. static inline bool
  2668. bfd_section_is_ctf (const asection *sec)
  2669. {
  2670. const char *name = bfd_section_name (sec);
  2671. return startswith (name, ".ctf") && (name[4] == 0 || name[4] == '.');
  2672. }
  2673. #ifdef __cplusplus
  2674. }
  2675. #endif
  2676. #endif /* _LIBELF_H_ */