coff-alpha.c 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393
  1. /* BFD back-end for ALPHA Extended-Coff files.
  2. Copyright (C) 1993-2015 Free Software Foundation, Inc.
  3. Modified from coff-mips.c by Steve Chamberlain <sac@cygnus.com> and
  4. Ian Lance Taylor <ian@cygnus.com>.
  5. This file is part of BFD, the Binary File Descriptor library.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  17. MA 02110-1301, USA. */
  18. #include "sysdep.h"
  19. #include "bfd.h"
  20. #include "bfdlink.h"
  21. #include "libbfd.h"
  22. #include "coff/internal.h"
  23. #include "coff/sym.h"
  24. #include "coff/symconst.h"
  25. #include "coff/ecoff.h"
  26. #include "coff/alpha.h"
  27. #include "aout/ar.h"
  28. #include "libcoff.h"
  29. #include "libecoff.h"
  30. /* Prototypes for static functions. */
  31. /* ECOFF has COFF sections, but the debugging information is stored in
  32. a completely different format. ECOFF targets use some of the
  33. swapping routines from coffswap.h, and some of the generic COFF
  34. routines in coffgen.c, but, unlike the real COFF targets, do not
  35. use coffcode.h itself.
  36. Get the generic COFF swapping routines, except for the reloc,
  37. symbol, and lineno ones. Give them ecoff names. Define some
  38. accessor macros for the large sizes used for Alpha ECOFF. */
  39. #define GET_FILEHDR_SYMPTR H_GET_64
  40. #define PUT_FILEHDR_SYMPTR H_PUT_64
  41. #define GET_AOUTHDR_TSIZE H_GET_64
  42. #define PUT_AOUTHDR_TSIZE H_PUT_64
  43. #define GET_AOUTHDR_DSIZE H_GET_64
  44. #define PUT_AOUTHDR_DSIZE H_PUT_64
  45. #define GET_AOUTHDR_BSIZE H_GET_64
  46. #define PUT_AOUTHDR_BSIZE H_PUT_64
  47. #define GET_AOUTHDR_ENTRY H_GET_64
  48. #define PUT_AOUTHDR_ENTRY H_PUT_64
  49. #define GET_AOUTHDR_TEXT_START H_GET_64
  50. #define PUT_AOUTHDR_TEXT_START H_PUT_64
  51. #define GET_AOUTHDR_DATA_START H_GET_64
  52. #define PUT_AOUTHDR_DATA_START H_PUT_64
  53. #define GET_SCNHDR_PADDR H_GET_64
  54. #define PUT_SCNHDR_PADDR H_PUT_64
  55. #define GET_SCNHDR_VADDR H_GET_64
  56. #define PUT_SCNHDR_VADDR H_PUT_64
  57. #define GET_SCNHDR_SIZE H_GET_64
  58. #define PUT_SCNHDR_SIZE H_PUT_64
  59. #define GET_SCNHDR_SCNPTR H_GET_64
  60. #define PUT_SCNHDR_SCNPTR H_PUT_64
  61. #define GET_SCNHDR_RELPTR H_GET_64
  62. #define PUT_SCNHDR_RELPTR H_PUT_64
  63. #define GET_SCNHDR_LNNOPTR H_GET_64
  64. #define PUT_SCNHDR_LNNOPTR H_PUT_64
  65. #define ALPHAECOFF
  66. #define NO_COFF_RELOCS
  67. #define NO_COFF_SYMBOLS
  68. #define NO_COFF_LINENOS
  69. #define coff_swap_filehdr_in alpha_ecoff_swap_filehdr_in
  70. #define coff_swap_filehdr_out alpha_ecoff_swap_filehdr_out
  71. #define coff_swap_aouthdr_in alpha_ecoff_swap_aouthdr_in
  72. #define coff_swap_aouthdr_out alpha_ecoff_swap_aouthdr_out
  73. #define coff_swap_scnhdr_in alpha_ecoff_swap_scnhdr_in
  74. #define coff_swap_scnhdr_out alpha_ecoff_swap_scnhdr_out
  75. #include "coffswap.h"
  76. /* Get the ECOFF swapping routines. */
  77. #define ECOFF_64
  78. #include "ecoffswap.h"
  79. /* How to process the various reloc types. */
  80. static bfd_reloc_status_type
  81. reloc_nil (bfd *abfd ATTRIBUTE_UNUSED,
  82. arelent *reloc ATTRIBUTE_UNUSED,
  83. asymbol *sym ATTRIBUTE_UNUSED,
  84. void * data ATTRIBUTE_UNUSED,
  85. asection *sec ATTRIBUTE_UNUSED,
  86. bfd *output_bfd ATTRIBUTE_UNUSED,
  87. char **error_message ATTRIBUTE_UNUSED)
  88. {
  89. return bfd_reloc_ok;
  90. }
  91. /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
  92. from smaller values. Start with zero, widen, *then* decrement. */
  93. #define MINUS_ONE (((bfd_vma)0) - 1)
  94. static reloc_howto_type alpha_howto_table[] =
  95. {
  96. /* Reloc type 0 is ignored by itself. However, it appears after a
  97. GPDISP reloc to identify the location where the low order 16 bits
  98. of the gp register are loaded. */
  99. HOWTO (ALPHA_R_IGNORE, /* type */
  100. 0, /* rightshift */
  101. 0, /* size (0 = byte, 1 = short, 2 = long) */
  102. 8, /* bitsize */
  103. TRUE, /* pc_relative */
  104. 0, /* bitpos */
  105. complain_overflow_dont, /* complain_on_overflow */
  106. reloc_nil, /* special_function */
  107. "IGNORE", /* name */
  108. TRUE, /* partial_inplace */
  109. 0, /* src_mask */
  110. 0, /* dst_mask */
  111. TRUE), /* pcrel_offset */
  112. /* A 32 bit reference to a symbol. */
  113. HOWTO (ALPHA_R_REFLONG, /* type */
  114. 0, /* rightshift */
  115. 2, /* size (0 = byte, 1 = short, 2 = long) */
  116. 32, /* bitsize */
  117. FALSE, /* pc_relative */
  118. 0, /* bitpos */
  119. complain_overflow_bitfield, /* complain_on_overflow */
  120. 0, /* special_function */
  121. "REFLONG", /* name */
  122. TRUE, /* partial_inplace */
  123. 0xffffffff, /* src_mask */
  124. 0xffffffff, /* dst_mask */
  125. FALSE), /* pcrel_offset */
  126. /* A 64 bit reference to a symbol. */
  127. HOWTO (ALPHA_R_REFQUAD, /* type */
  128. 0, /* rightshift */
  129. 4, /* size (0 = byte, 1 = short, 2 = long) */
  130. 64, /* bitsize */
  131. FALSE, /* pc_relative */
  132. 0, /* bitpos */
  133. complain_overflow_bitfield, /* complain_on_overflow */
  134. 0, /* special_function */
  135. "REFQUAD", /* name */
  136. TRUE, /* partial_inplace */
  137. MINUS_ONE, /* src_mask */
  138. MINUS_ONE, /* dst_mask */
  139. FALSE), /* pcrel_offset */
  140. /* A 32 bit GP relative offset. This is just like REFLONG except
  141. that when the value is used the value of the gp register will be
  142. added in. */
  143. HOWTO (ALPHA_R_GPREL32, /* type */
  144. 0, /* rightshift */
  145. 2, /* size (0 = byte, 1 = short, 2 = long) */
  146. 32, /* bitsize */
  147. FALSE, /* pc_relative */
  148. 0, /* bitpos */
  149. complain_overflow_bitfield, /* complain_on_overflow */
  150. 0, /* special_function */
  151. "GPREL32", /* name */
  152. TRUE, /* partial_inplace */
  153. 0xffffffff, /* src_mask */
  154. 0xffffffff, /* dst_mask */
  155. FALSE), /* pcrel_offset */
  156. /* Used for an instruction that refers to memory off the GP
  157. register. The offset is 16 bits of the 32 bit instruction. This
  158. reloc always seems to be against the .lita section. */
  159. HOWTO (ALPHA_R_LITERAL, /* type */
  160. 0, /* rightshift */
  161. 2, /* size (0 = byte, 1 = short, 2 = long) */
  162. 16, /* bitsize */
  163. FALSE, /* pc_relative */
  164. 0, /* bitpos */
  165. complain_overflow_signed, /* complain_on_overflow */
  166. 0, /* special_function */
  167. "LITERAL", /* name */
  168. TRUE, /* partial_inplace */
  169. 0xffff, /* src_mask */
  170. 0xffff, /* dst_mask */
  171. FALSE), /* pcrel_offset */
  172. /* This reloc only appears immediately following a LITERAL reloc.
  173. It identifies a use of the literal. It seems that the linker can
  174. use this to eliminate a portion of the .lita section. The symbol
  175. index is special: 1 means the literal address is in the base
  176. register of a memory format instruction; 2 means the literal
  177. address is in the byte offset register of a byte-manipulation
  178. instruction; 3 means the literal address is in the target
  179. register of a jsr instruction. This does not actually do any
  180. relocation. */
  181. HOWTO (ALPHA_R_LITUSE, /* type */
  182. 0, /* rightshift */
  183. 2, /* size (0 = byte, 1 = short, 2 = long) */
  184. 32, /* bitsize */
  185. FALSE, /* pc_relative */
  186. 0, /* bitpos */
  187. complain_overflow_dont, /* complain_on_overflow */
  188. reloc_nil, /* special_function */
  189. "LITUSE", /* name */
  190. FALSE, /* partial_inplace */
  191. 0, /* src_mask */
  192. 0, /* dst_mask */
  193. FALSE), /* pcrel_offset */
  194. /* Load the gp register. This is always used for a ldah instruction
  195. which loads the upper 16 bits of the gp register. The next reloc
  196. will be an IGNORE reloc which identifies the location of the lda
  197. instruction which loads the lower 16 bits. The symbol index of
  198. the GPDISP instruction appears to actually be the number of bytes
  199. between the ldah and lda instructions. This gives two different
  200. ways to determine where the lda instruction is; I don't know why
  201. both are used. The value to use for the relocation is the
  202. difference between the GP value and the current location; the
  203. load will always be done against a register holding the current
  204. address. */
  205. HOWTO (ALPHA_R_GPDISP, /* type */
  206. 16, /* rightshift */
  207. 2, /* size (0 = byte, 1 = short, 2 = long) */
  208. 16, /* bitsize */
  209. TRUE, /* pc_relative */
  210. 0, /* bitpos */
  211. complain_overflow_dont, /* complain_on_overflow */
  212. reloc_nil, /* special_function */
  213. "GPDISP", /* name */
  214. TRUE, /* partial_inplace */
  215. 0xffff, /* src_mask */
  216. 0xffff, /* dst_mask */
  217. TRUE), /* pcrel_offset */
  218. /* A 21 bit branch. The native assembler generates these for
  219. branches within the text segment, and also fills in the PC
  220. relative offset in the instruction. */
  221. HOWTO (ALPHA_R_BRADDR, /* type */
  222. 2, /* rightshift */
  223. 2, /* size (0 = byte, 1 = short, 2 = long) */
  224. 21, /* bitsize */
  225. TRUE, /* pc_relative */
  226. 0, /* bitpos */
  227. complain_overflow_signed, /* complain_on_overflow */
  228. 0, /* special_function */
  229. "BRADDR", /* name */
  230. TRUE, /* partial_inplace */
  231. 0x1fffff, /* src_mask */
  232. 0x1fffff, /* dst_mask */
  233. FALSE), /* pcrel_offset */
  234. /* A hint for a jump to a register. */
  235. HOWTO (ALPHA_R_HINT, /* type */
  236. 2, /* rightshift */
  237. 2, /* size (0 = byte, 1 = short, 2 = long) */
  238. 14, /* bitsize */
  239. TRUE, /* pc_relative */
  240. 0, /* bitpos */
  241. complain_overflow_dont, /* complain_on_overflow */
  242. 0, /* special_function */
  243. "HINT", /* name */
  244. TRUE, /* partial_inplace */
  245. 0x3fff, /* src_mask */
  246. 0x3fff, /* dst_mask */
  247. FALSE), /* pcrel_offset */
  248. /* 16 bit PC relative offset. */
  249. HOWTO (ALPHA_R_SREL16, /* type */
  250. 0, /* rightshift */
  251. 1, /* size (0 = byte, 1 = short, 2 = long) */
  252. 16, /* bitsize */
  253. TRUE, /* pc_relative */
  254. 0, /* bitpos */
  255. complain_overflow_signed, /* complain_on_overflow */
  256. 0, /* special_function */
  257. "SREL16", /* name */
  258. TRUE, /* partial_inplace */
  259. 0xffff, /* src_mask */
  260. 0xffff, /* dst_mask */
  261. FALSE), /* pcrel_offset */
  262. /* 32 bit PC relative offset. */
  263. HOWTO (ALPHA_R_SREL32, /* type */
  264. 0, /* rightshift */
  265. 2, /* size (0 = byte, 1 = short, 2 = long) */
  266. 32, /* bitsize */
  267. TRUE, /* pc_relative */
  268. 0, /* bitpos */
  269. complain_overflow_signed, /* complain_on_overflow */
  270. 0, /* special_function */
  271. "SREL32", /* name */
  272. TRUE, /* partial_inplace */
  273. 0xffffffff, /* src_mask */
  274. 0xffffffff, /* dst_mask */
  275. FALSE), /* pcrel_offset */
  276. /* A 64 bit PC relative offset. */
  277. HOWTO (ALPHA_R_SREL64, /* type */
  278. 0, /* rightshift */
  279. 4, /* size (0 = byte, 1 = short, 2 = long) */
  280. 64, /* bitsize */
  281. TRUE, /* pc_relative */
  282. 0, /* bitpos */
  283. complain_overflow_signed, /* complain_on_overflow */
  284. 0, /* special_function */
  285. "SREL64", /* name */
  286. TRUE, /* partial_inplace */
  287. MINUS_ONE, /* src_mask */
  288. MINUS_ONE, /* dst_mask */
  289. FALSE), /* pcrel_offset */
  290. /* Push a value on the reloc evaluation stack. */
  291. HOWTO (ALPHA_R_OP_PUSH, /* type */
  292. 0, /* rightshift */
  293. 0, /* size (0 = byte, 1 = short, 2 = long) */
  294. 0, /* bitsize */
  295. FALSE, /* pc_relative */
  296. 0, /* bitpos */
  297. complain_overflow_dont, /* complain_on_overflow */
  298. 0, /* special_function */
  299. "OP_PUSH", /* name */
  300. FALSE, /* partial_inplace */
  301. 0, /* src_mask */
  302. 0, /* dst_mask */
  303. FALSE), /* pcrel_offset */
  304. /* Store the value from the stack at the given address. Store it in
  305. a bitfield of size r_size starting at bit position r_offset. */
  306. HOWTO (ALPHA_R_OP_STORE, /* type */
  307. 0, /* rightshift */
  308. 4, /* size (0 = byte, 1 = short, 2 = long) */
  309. 64, /* bitsize */
  310. FALSE, /* pc_relative */
  311. 0, /* bitpos */
  312. complain_overflow_dont, /* complain_on_overflow */
  313. 0, /* special_function */
  314. "OP_STORE", /* name */
  315. FALSE, /* partial_inplace */
  316. 0, /* src_mask */
  317. MINUS_ONE, /* dst_mask */
  318. FALSE), /* pcrel_offset */
  319. /* Subtract the reloc address from the value on the top of the
  320. relocation stack. */
  321. HOWTO (ALPHA_R_OP_PSUB, /* type */
  322. 0, /* rightshift */
  323. 0, /* size (0 = byte, 1 = short, 2 = long) */
  324. 0, /* bitsize */
  325. FALSE, /* pc_relative */
  326. 0, /* bitpos */
  327. complain_overflow_dont, /* complain_on_overflow */
  328. 0, /* special_function */
  329. "OP_PSUB", /* name */
  330. FALSE, /* partial_inplace */
  331. 0, /* src_mask */
  332. 0, /* dst_mask */
  333. FALSE), /* pcrel_offset */
  334. /* Shift the value on the top of the relocation stack right by the
  335. given value. */
  336. HOWTO (ALPHA_R_OP_PRSHIFT, /* type */
  337. 0, /* rightshift */
  338. 0, /* size (0 = byte, 1 = short, 2 = long) */
  339. 0, /* bitsize */
  340. FALSE, /* pc_relative */
  341. 0, /* bitpos */
  342. complain_overflow_dont, /* complain_on_overflow */
  343. 0, /* special_function */
  344. "OP_PRSHIFT", /* name */
  345. FALSE, /* partial_inplace */
  346. 0, /* src_mask */
  347. 0, /* dst_mask */
  348. FALSE), /* pcrel_offset */
  349. /* Adjust the GP value for a new range in the object file. */
  350. HOWTO (ALPHA_R_GPVALUE, /* type */
  351. 0, /* rightshift */
  352. 0, /* size (0 = byte, 1 = short, 2 = long) */
  353. 0, /* bitsize */
  354. FALSE, /* pc_relative */
  355. 0, /* bitpos */
  356. complain_overflow_dont, /* complain_on_overflow */
  357. 0, /* special_function */
  358. "GPVALUE", /* name */
  359. FALSE, /* partial_inplace */
  360. 0, /* src_mask */
  361. 0, /* dst_mask */
  362. FALSE) /* pcrel_offset */
  363. };
  364. /* Recognize an Alpha ECOFF file. */
  365. static const bfd_target *
  366. alpha_ecoff_object_p (bfd *abfd)
  367. {
  368. static const bfd_target *ret;
  369. ret = coff_object_p (abfd);
  370. if (ret != NULL)
  371. {
  372. asection *sec;
  373. /* Alpha ECOFF has a .pdata section. The lnnoptr field of the
  374. .pdata section is the number of entries it contains. Each
  375. entry takes up 8 bytes. The number of entries is required
  376. since the section is aligned to a 16 byte boundary. When we
  377. link .pdata sections together, we do not want to include the
  378. alignment bytes. We handle this on input by faking the size
  379. of the .pdata section to remove the unwanted alignment bytes.
  380. On output we will set the lnnoptr field and force the
  381. alignment. */
  382. sec = bfd_get_section_by_name (abfd, _PDATA);
  383. if (sec != (asection *) NULL)
  384. {
  385. bfd_size_type size;
  386. size = sec->line_filepos * 8;
  387. BFD_ASSERT (size == sec->size
  388. || size + 8 == sec->size);
  389. if (! bfd_set_section_size (abfd, sec, size))
  390. return NULL;
  391. }
  392. }
  393. return ret;
  394. }
  395. /* See whether the magic number matches. */
  396. static bfd_boolean
  397. alpha_ecoff_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED,
  398. void * filehdr)
  399. {
  400. struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
  401. if (! ALPHA_ECOFF_BADMAG (*internal_f))
  402. return TRUE;
  403. if (ALPHA_ECOFF_COMPRESSEDMAG (*internal_f))
  404. (*_bfd_error_handler)
  405. (_("%B: Cannot handle compressed Alpha binaries.\n"
  406. " Use compiler flags, or objZ, to generate uncompressed binaries."),
  407. abfd);
  408. return FALSE;
  409. }
  410. /* This is a hook called by coff_real_object_p to create any backend
  411. specific information. */
  412. static void *
  413. alpha_ecoff_mkobject_hook (bfd *abfd, void * filehdr, void * aouthdr)
  414. {
  415. void * ecoff;
  416. ecoff = _bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr);
  417. if (ecoff != NULL)
  418. {
  419. struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
  420. /* Set additional BFD flags according to the object type from the
  421. machine specific file header flags. */
  422. switch (internal_f->f_flags & F_ALPHA_OBJECT_TYPE_MASK)
  423. {
  424. case F_ALPHA_SHARABLE:
  425. abfd->flags |= DYNAMIC;
  426. break;
  427. case F_ALPHA_CALL_SHARED:
  428. /* Always executable if using shared libraries as the run time
  429. loader might resolve undefined references. */
  430. abfd->flags |= (DYNAMIC | EXEC_P);
  431. break;
  432. }
  433. }
  434. return ecoff;
  435. }
  436. /* Reloc handling. */
  437. /* Swap a reloc in. */
  438. static void
  439. alpha_ecoff_swap_reloc_in (bfd *abfd,
  440. void * ext_ptr,
  441. struct internal_reloc *intern)
  442. {
  443. const RELOC *ext = (RELOC *) ext_ptr;
  444. intern->r_vaddr = H_GET_64 (abfd, ext->r_vaddr);
  445. intern->r_symndx = H_GET_32 (abfd, ext->r_symndx);
  446. BFD_ASSERT (bfd_header_little_endian (abfd));
  447. intern->r_type = ((ext->r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
  448. >> RELOC_BITS0_TYPE_SH_LITTLE);
  449. intern->r_extern = (ext->r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0;
  450. intern->r_offset = ((ext->r_bits[1] & RELOC_BITS1_OFFSET_LITTLE)
  451. >> RELOC_BITS1_OFFSET_SH_LITTLE);
  452. /* Ignored the reserved bits. */
  453. intern->r_size = ((ext->r_bits[3] & RELOC_BITS3_SIZE_LITTLE)
  454. >> RELOC_BITS3_SIZE_SH_LITTLE);
  455. if (intern->r_type == ALPHA_R_LITUSE
  456. || intern->r_type == ALPHA_R_GPDISP)
  457. {
  458. /* Handle the LITUSE and GPDISP relocs specially. Its symndx
  459. value is not actually a symbol index, but is instead a
  460. special code. We put the code in the r_size field, and
  461. clobber the symndx. */
  462. if (intern->r_size != 0)
  463. abort ();
  464. intern->r_size = intern->r_symndx;
  465. intern->r_symndx = RELOC_SECTION_NONE;
  466. }
  467. else if (intern->r_type == ALPHA_R_IGNORE)
  468. {
  469. /* The IGNORE reloc generally follows a GPDISP reloc, and is
  470. against the .lita section. The section is irrelevant. */
  471. if (! intern->r_extern &&
  472. intern->r_symndx == RELOC_SECTION_ABS)
  473. abort ();
  474. if (! intern->r_extern && intern->r_symndx == RELOC_SECTION_LITA)
  475. intern->r_symndx = RELOC_SECTION_ABS;
  476. }
  477. }
  478. /* Swap a reloc out. */
  479. static void
  480. alpha_ecoff_swap_reloc_out (bfd *abfd,
  481. const struct internal_reloc *intern,
  482. void * dst)
  483. {
  484. RELOC *ext = (RELOC *) dst;
  485. long symndx;
  486. unsigned char size;
  487. /* Undo the hackery done in swap_reloc_in. */
  488. if (intern->r_type == ALPHA_R_LITUSE
  489. || intern->r_type == ALPHA_R_GPDISP)
  490. {
  491. symndx = intern->r_size;
  492. size = 0;
  493. }
  494. else if (intern->r_type == ALPHA_R_IGNORE
  495. && ! intern->r_extern
  496. && intern->r_symndx == RELOC_SECTION_ABS)
  497. {
  498. symndx = RELOC_SECTION_LITA;
  499. size = intern->r_size;
  500. }
  501. else
  502. {
  503. symndx = intern->r_symndx;
  504. size = intern->r_size;
  505. }
  506. /* XXX FIXME: The maximum symndx value used to be 14 but this
  507. fails with object files produced by DEC's C++ compiler.
  508. Where does the value 14 (or 15) come from anyway ? */
  509. BFD_ASSERT (intern->r_extern
  510. || (intern->r_symndx >= 0 && intern->r_symndx <= 15));
  511. H_PUT_64 (abfd, intern->r_vaddr, ext->r_vaddr);
  512. H_PUT_32 (abfd, symndx, ext->r_symndx);
  513. BFD_ASSERT (bfd_header_little_endian (abfd));
  514. ext->r_bits[0] = ((intern->r_type << RELOC_BITS0_TYPE_SH_LITTLE)
  515. & RELOC_BITS0_TYPE_LITTLE);
  516. ext->r_bits[1] = ((intern->r_extern ? RELOC_BITS1_EXTERN_LITTLE : 0)
  517. | ((intern->r_offset << RELOC_BITS1_OFFSET_SH_LITTLE)
  518. & RELOC_BITS1_OFFSET_LITTLE));
  519. ext->r_bits[2] = 0;
  520. ext->r_bits[3] = ((size << RELOC_BITS3_SIZE_SH_LITTLE)
  521. & RELOC_BITS3_SIZE_LITTLE);
  522. }
  523. /* Finish canonicalizing a reloc. Part of this is generic to all
  524. ECOFF targets, and that part is in ecoff.c. The rest is done in
  525. this backend routine. It must fill in the howto field. */
  526. static void
  527. alpha_adjust_reloc_in (bfd *abfd,
  528. const struct internal_reloc *intern,
  529. arelent *rptr)
  530. {
  531. if (intern->r_type > ALPHA_R_GPVALUE)
  532. {
  533. (*_bfd_error_handler)
  534. (_("%B: unknown/unsupported relocation type %d"),
  535. abfd, intern->r_type);
  536. bfd_set_error (bfd_error_bad_value);
  537. rptr->addend = 0;
  538. rptr->howto = NULL;
  539. return;
  540. }
  541. switch (intern->r_type)
  542. {
  543. case ALPHA_R_BRADDR:
  544. case ALPHA_R_SREL16:
  545. case ALPHA_R_SREL32:
  546. case ALPHA_R_SREL64:
  547. /* This relocs appear to be fully resolved when they are against
  548. internal symbols. Against external symbols, BRADDR at least
  549. appears to be resolved against the next instruction. */
  550. if (! intern->r_extern)
  551. rptr->addend = 0;
  552. else
  553. rptr->addend = - (intern->r_vaddr + 4);
  554. break;
  555. case ALPHA_R_GPREL32:
  556. case ALPHA_R_LITERAL:
  557. /* Copy the gp value for this object file into the addend, to
  558. ensure that we are not confused by the linker. */
  559. if (! intern->r_extern)
  560. rptr->addend += ecoff_data (abfd)->gp;
  561. break;
  562. case ALPHA_R_LITUSE:
  563. case ALPHA_R_GPDISP:
  564. /* The LITUSE and GPDISP relocs do not use a symbol, or an
  565. addend, but they do use a special code. Put this code in the
  566. addend field. */
  567. rptr->addend = intern->r_size;
  568. break;
  569. case ALPHA_R_OP_STORE:
  570. /* The STORE reloc needs the size and offset fields. We store
  571. them in the addend. */
  572. BFD_ASSERT (intern->r_offset <= 256);
  573. rptr->addend = (intern->r_offset << 8) + intern->r_size;
  574. break;
  575. case ALPHA_R_OP_PUSH:
  576. case ALPHA_R_OP_PSUB:
  577. case ALPHA_R_OP_PRSHIFT:
  578. /* The PUSH, PSUB and PRSHIFT relocs do not actually use an
  579. address. I believe that the address supplied is really an
  580. addend. */
  581. rptr->addend = intern->r_vaddr;
  582. break;
  583. case ALPHA_R_GPVALUE:
  584. /* Set the addend field to the new GP value. */
  585. rptr->addend = intern->r_symndx + ecoff_data (abfd)->gp;
  586. break;
  587. case ALPHA_R_IGNORE:
  588. /* If the type is ALPHA_R_IGNORE, make sure this is a reference
  589. to the absolute section so that the reloc is ignored. For
  590. some reason the address of this reloc type is not adjusted by
  591. the section vma. We record the gp value for this object file
  592. here, for convenience when doing the GPDISP relocation. */
  593. rptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
  594. rptr->address = intern->r_vaddr;
  595. rptr->addend = ecoff_data (abfd)->gp;
  596. break;
  597. default:
  598. break;
  599. }
  600. rptr->howto = &alpha_howto_table[intern->r_type];
  601. }
  602. /* When writing out a reloc we need to pull some values back out of
  603. the addend field into the reloc. This is roughly the reverse of
  604. alpha_adjust_reloc_in, except that there are several changes we do
  605. not need to undo. */
  606. static void
  607. alpha_adjust_reloc_out (bfd *abfd ATTRIBUTE_UNUSED,
  608. const arelent *rel,
  609. struct internal_reloc *intern)
  610. {
  611. switch (intern->r_type)
  612. {
  613. case ALPHA_R_LITUSE:
  614. case ALPHA_R_GPDISP:
  615. intern->r_size = rel->addend;
  616. break;
  617. case ALPHA_R_OP_STORE:
  618. intern->r_size = rel->addend & 0xff;
  619. intern->r_offset = (rel->addend >> 8) & 0xff;
  620. break;
  621. case ALPHA_R_OP_PUSH:
  622. case ALPHA_R_OP_PSUB:
  623. case ALPHA_R_OP_PRSHIFT:
  624. intern->r_vaddr = rel->addend;
  625. break;
  626. case ALPHA_R_IGNORE:
  627. intern->r_vaddr = rel->address;
  628. break;
  629. default:
  630. break;
  631. }
  632. }
  633. /* The size of the stack for the relocation evaluator. */
  634. #define RELOC_STACKSIZE (10)
  635. /* Alpha ECOFF relocs have a built in expression evaluator as well as
  636. other interdependencies. Rather than use a bunch of special
  637. functions and global variables, we use a single routine to do all
  638. the relocation for a section. I haven't yet worked out how the
  639. assembler is going to handle this. */
  640. static bfd_byte *
  641. alpha_ecoff_get_relocated_section_contents (bfd *abfd,
  642. struct bfd_link_info *link_info,
  643. struct bfd_link_order *link_order,
  644. bfd_byte *data,
  645. bfd_boolean relocatable,
  646. asymbol **symbols)
  647. {
  648. bfd *input_bfd = link_order->u.indirect.section->owner;
  649. asection *input_section = link_order->u.indirect.section;
  650. long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
  651. arelent **reloc_vector = NULL;
  652. long reloc_count;
  653. bfd *output_bfd = relocatable ? abfd : (bfd *) NULL;
  654. bfd_vma gp;
  655. bfd_size_type sz;
  656. bfd_boolean gp_undefined;
  657. bfd_vma stack[RELOC_STACKSIZE];
  658. int tos = 0;
  659. if (reloc_size < 0)
  660. goto error_return;
  661. reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
  662. if (reloc_vector == NULL && reloc_size != 0)
  663. goto error_return;
  664. sz = input_section->rawsize ? input_section->rawsize : input_section->size;
  665. if (! bfd_get_section_contents (input_bfd, input_section, data, 0, sz))
  666. goto error_return;
  667. reloc_count = bfd_canonicalize_reloc (input_bfd, input_section,
  668. reloc_vector, symbols);
  669. if (reloc_count < 0)
  670. goto error_return;
  671. if (reloc_count == 0)
  672. goto successful_return;
  673. /* Get the GP value for the output BFD. */
  674. gp_undefined = FALSE;
  675. gp = _bfd_get_gp_value (abfd);
  676. if (gp == 0)
  677. {
  678. if (relocatable)
  679. {
  680. asection *sec;
  681. bfd_vma lo;
  682. /* Make up a value. */
  683. lo = (bfd_vma) -1;
  684. for (sec = abfd->sections; sec != NULL; sec = sec->next)
  685. {
  686. if (sec->vma < lo
  687. && (strcmp (sec->name, ".sbss") == 0
  688. || strcmp (sec->name, ".sdata") == 0
  689. || strcmp (sec->name, ".lit4") == 0
  690. || strcmp (sec->name, ".lit8") == 0
  691. || strcmp (sec->name, ".lita") == 0))
  692. lo = sec->vma;
  693. }
  694. gp = lo + 0x8000;
  695. _bfd_set_gp_value (abfd, gp);
  696. }
  697. else
  698. {
  699. struct bfd_link_hash_entry *h;
  700. h = bfd_link_hash_lookup (link_info->hash, "_gp", FALSE, FALSE,
  701. TRUE);
  702. if (h == (struct bfd_link_hash_entry *) NULL
  703. || h->type != bfd_link_hash_defined)
  704. gp_undefined = TRUE;
  705. else
  706. {
  707. gp = (h->u.def.value
  708. + h->u.def.section->output_section->vma
  709. + h->u.def.section->output_offset);
  710. _bfd_set_gp_value (abfd, gp);
  711. }
  712. }
  713. }
  714. for (; *reloc_vector != (arelent *) NULL; reloc_vector++)
  715. {
  716. arelent *rel;
  717. bfd_reloc_status_type r;
  718. char *err;
  719. rel = *reloc_vector;
  720. r = bfd_reloc_ok;
  721. switch (rel->howto->type)
  722. {
  723. case ALPHA_R_IGNORE:
  724. rel->address += input_section->output_offset;
  725. break;
  726. case ALPHA_R_REFLONG:
  727. case ALPHA_R_REFQUAD:
  728. case ALPHA_R_BRADDR:
  729. case ALPHA_R_HINT:
  730. case ALPHA_R_SREL16:
  731. case ALPHA_R_SREL32:
  732. case ALPHA_R_SREL64:
  733. if (relocatable
  734. && ((*rel->sym_ptr_ptr)->flags & BSF_SECTION_SYM) == 0)
  735. {
  736. rel->address += input_section->output_offset;
  737. break;
  738. }
  739. r = bfd_perform_relocation (input_bfd, rel, data, input_section,
  740. output_bfd, &err);
  741. break;
  742. case ALPHA_R_GPREL32:
  743. /* This relocation is used in a switch table. It is a 32
  744. bit offset from the current GP value. We must adjust it
  745. by the different between the original GP value and the
  746. current GP value. The original GP value is stored in the
  747. addend. We adjust the addend and let
  748. bfd_perform_relocation finish the job. */
  749. rel->addend -= gp;
  750. r = bfd_perform_relocation (input_bfd, rel, data, input_section,
  751. output_bfd, &err);
  752. if (r == bfd_reloc_ok && gp_undefined)
  753. {
  754. r = bfd_reloc_dangerous;
  755. err = (char *) _("GP relative relocation used when GP not defined");
  756. }
  757. break;
  758. case ALPHA_R_LITERAL:
  759. /* This is a reference to a literal value, generally
  760. (always?) in the .lita section. This is a 16 bit GP
  761. relative relocation. Sometimes the subsequent reloc is a
  762. LITUSE reloc, which indicates how this reloc is used.
  763. This sometimes permits rewriting the two instructions
  764. referred to by the LITERAL and the LITUSE into different
  765. instructions which do not refer to .lita. This can save
  766. a memory reference, and permits removing a value from
  767. .lita thus saving GP relative space.
  768. We do not these optimizations. To do them we would need
  769. to arrange to link the .lita section first, so that by
  770. the time we got here we would know the final values to
  771. use. This would not be particularly difficult, but it is
  772. not currently implemented. */
  773. {
  774. unsigned long insn;
  775. /* I believe that the LITERAL reloc will only apply to a
  776. ldq or ldl instruction, so check my assumption. */
  777. insn = bfd_get_32 (input_bfd, data + rel->address);
  778. BFD_ASSERT (((insn >> 26) & 0x3f) == 0x29
  779. || ((insn >> 26) & 0x3f) == 0x28);
  780. rel->addend -= gp;
  781. r = bfd_perform_relocation (input_bfd, rel, data, input_section,
  782. output_bfd, &err);
  783. if (r == bfd_reloc_ok && gp_undefined)
  784. {
  785. r = bfd_reloc_dangerous;
  786. err =
  787. (char *) _("GP relative relocation used when GP not defined");
  788. }
  789. }
  790. break;
  791. case ALPHA_R_LITUSE:
  792. /* See ALPHA_R_LITERAL above for the uses of this reloc. It
  793. does not cause anything to happen, itself. */
  794. rel->address += input_section->output_offset;
  795. break;
  796. case ALPHA_R_GPDISP:
  797. /* This marks the ldah of an ldah/lda pair which loads the
  798. gp register with the difference of the gp value and the
  799. current location. The second of the pair is r_size bytes
  800. ahead; it used to be marked with an ALPHA_R_IGNORE reloc,
  801. but that no longer happens in OSF/1 3.2. */
  802. {
  803. unsigned long insn1, insn2;
  804. bfd_vma addend;
  805. /* Get the two instructions. */
  806. insn1 = bfd_get_32 (input_bfd, data + rel->address);
  807. insn2 = bfd_get_32 (input_bfd, data + rel->address + rel->addend);
  808. BFD_ASSERT (((insn1 >> 26) & 0x3f) == 0x09); /* ldah */
  809. BFD_ASSERT (((insn2 >> 26) & 0x3f) == 0x08); /* lda */
  810. /* Get the existing addend. We must account for the sign
  811. extension done by lda and ldah. */
  812. addend = ((insn1 & 0xffff) << 16) + (insn2 & 0xffff);
  813. if (insn1 & 0x8000)
  814. {
  815. addend -= 0x80000000;
  816. addend -= 0x80000000;
  817. }
  818. if (insn2 & 0x8000)
  819. addend -= 0x10000;
  820. /* The existing addend includes the different between the
  821. gp of the input BFD and the address in the input BFD.
  822. Subtract this out. */
  823. addend -= (ecoff_data (input_bfd)->gp
  824. - (input_section->vma + rel->address));
  825. /* Now add in the final gp value, and subtract out the
  826. final address. */
  827. addend += (gp
  828. - (input_section->output_section->vma
  829. + input_section->output_offset
  830. + rel->address));
  831. /* Change the instructions, accounting for the sign
  832. extension, and write them out. */
  833. if (addend & 0x8000)
  834. addend += 0x10000;
  835. insn1 = (insn1 & 0xffff0000) | ((addend >> 16) & 0xffff);
  836. insn2 = (insn2 & 0xffff0000) | (addend & 0xffff);
  837. bfd_put_32 (input_bfd, (bfd_vma) insn1, data + rel->address);
  838. bfd_put_32 (input_bfd, (bfd_vma) insn2,
  839. data + rel->address + rel->addend);
  840. rel->address += input_section->output_offset;
  841. }
  842. break;
  843. case ALPHA_R_OP_PUSH:
  844. /* Push a value on the reloc evaluation stack. */
  845. {
  846. asymbol *symbol;
  847. bfd_vma relocation;
  848. if (relocatable)
  849. {
  850. rel->address += input_section->output_offset;
  851. break;
  852. }
  853. /* Figure out the relocation of this symbol. */
  854. symbol = *rel->sym_ptr_ptr;
  855. if (bfd_is_und_section (symbol->section))
  856. r = bfd_reloc_undefined;
  857. if (bfd_is_com_section (symbol->section))
  858. relocation = 0;
  859. else
  860. relocation = symbol->value;
  861. relocation += symbol->section->output_section->vma;
  862. relocation += symbol->section->output_offset;
  863. relocation += rel->addend;
  864. if (tos >= RELOC_STACKSIZE)
  865. abort ();
  866. stack[tos++] = relocation;
  867. }
  868. break;
  869. case ALPHA_R_OP_STORE:
  870. /* Store a value from the reloc stack into a bitfield. */
  871. {
  872. bfd_vma val;
  873. int offset, size;
  874. if (relocatable)
  875. {
  876. rel->address += input_section->output_offset;
  877. break;
  878. }
  879. if (tos == 0)
  880. abort ();
  881. /* The offset and size for this reloc are encoded into the
  882. addend field by alpha_adjust_reloc_in. */
  883. offset = (rel->addend >> 8) & 0xff;
  884. size = rel->addend & 0xff;
  885. val = bfd_get_64 (abfd, data + rel->address);
  886. val &=~ (((1 << size) - 1) << offset);
  887. val |= (stack[--tos] & ((1 << size) - 1)) << offset;
  888. bfd_put_64 (abfd, val, data + rel->address);
  889. }
  890. break;
  891. case ALPHA_R_OP_PSUB:
  892. /* Subtract a value from the top of the stack. */
  893. {
  894. asymbol *symbol;
  895. bfd_vma relocation;
  896. if (relocatable)
  897. {
  898. rel->address += input_section->output_offset;
  899. break;
  900. }
  901. /* Figure out the relocation of this symbol. */
  902. symbol = *rel->sym_ptr_ptr;
  903. if (bfd_is_und_section (symbol->section))
  904. r = bfd_reloc_undefined;
  905. if (bfd_is_com_section (symbol->section))
  906. relocation = 0;
  907. else
  908. relocation = symbol->value;
  909. relocation += symbol->section->output_section->vma;
  910. relocation += symbol->section->output_offset;
  911. relocation += rel->addend;
  912. if (tos == 0)
  913. abort ();
  914. stack[tos - 1] -= relocation;
  915. }
  916. break;
  917. case ALPHA_R_OP_PRSHIFT:
  918. /* Shift the value on the top of the stack. */
  919. {
  920. asymbol *symbol;
  921. bfd_vma relocation;
  922. if (relocatable)
  923. {
  924. rel->address += input_section->output_offset;
  925. break;
  926. }
  927. /* Figure out the relocation of this symbol. */
  928. symbol = *rel->sym_ptr_ptr;
  929. if (bfd_is_und_section (symbol->section))
  930. r = bfd_reloc_undefined;
  931. if (bfd_is_com_section (symbol->section))
  932. relocation = 0;
  933. else
  934. relocation = symbol->value;
  935. relocation += symbol->section->output_section->vma;
  936. relocation += symbol->section->output_offset;
  937. relocation += rel->addend;
  938. if (tos == 0)
  939. abort ();
  940. stack[tos - 1] >>= relocation;
  941. }
  942. break;
  943. case ALPHA_R_GPVALUE:
  944. /* I really don't know if this does the right thing. */
  945. gp = rel->addend;
  946. gp_undefined = FALSE;
  947. break;
  948. default:
  949. abort ();
  950. }
  951. if (relocatable)
  952. {
  953. asection *os = input_section->output_section;
  954. /* A partial link, so keep the relocs. */
  955. os->orelocation[os->reloc_count] = rel;
  956. os->reloc_count++;
  957. }
  958. if (r != bfd_reloc_ok)
  959. {
  960. switch (r)
  961. {
  962. case bfd_reloc_undefined:
  963. if (! ((*link_info->callbacks->undefined_symbol)
  964. (link_info, bfd_asymbol_name (*rel->sym_ptr_ptr),
  965. input_bfd, input_section, rel->address, TRUE)))
  966. goto error_return;
  967. break;
  968. case bfd_reloc_dangerous:
  969. if (! ((*link_info->callbacks->reloc_dangerous)
  970. (link_info, err, input_bfd, input_section,
  971. rel->address)))
  972. goto error_return;
  973. break;
  974. case bfd_reloc_overflow:
  975. if (! ((*link_info->callbacks->reloc_overflow)
  976. (link_info, NULL,
  977. bfd_asymbol_name (*rel->sym_ptr_ptr),
  978. rel->howto->name, rel->addend, input_bfd,
  979. input_section, rel->address)))
  980. goto error_return;
  981. break;
  982. case bfd_reloc_outofrange:
  983. default:
  984. abort ();
  985. break;
  986. }
  987. }
  988. }
  989. if (tos != 0)
  990. abort ();
  991. successful_return:
  992. if (reloc_vector != NULL)
  993. free (reloc_vector);
  994. return data;
  995. error_return:
  996. if (reloc_vector != NULL)
  997. free (reloc_vector);
  998. return NULL;
  999. }
  1000. /* Get the howto structure for a generic reloc type. */
  1001. static reloc_howto_type *
  1002. alpha_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
  1003. bfd_reloc_code_real_type code)
  1004. {
  1005. int alpha_type;
  1006. switch (code)
  1007. {
  1008. case BFD_RELOC_32:
  1009. alpha_type = ALPHA_R_REFLONG;
  1010. break;
  1011. case BFD_RELOC_64:
  1012. case BFD_RELOC_CTOR:
  1013. alpha_type = ALPHA_R_REFQUAD;
  1014. break;
  1015. case BFD_RELOC_GPREL32:
  1016. alpha_type = ALPHA_R_GPREL32;
  1017. break;
  1018. case BFD_RELOC_ALPHA_LITERAL:
  1019. alpha_type = ALPHA_R_LITERAL;
  1020. break;
  1021. case BFD_RELOC_ALPHA_LITUSE:
  1022. alpha_type = ALPHA_R_LITUSE;
  1023. break;
  1024. case BFD_RELOC_ALPHA_GPDISP_HI16:
  1025. alpha_type = ALPHA_R_GPDISP;
  1026. break;
  1027. case BFD_RELOC_ALPHA_GPDISP_LO16:
  1028. alpha_type = ALPHA_R_IGNORE;
  1029. break;
  1030. case BFD_RELOC_23_PCREL_S2:
  1031. alpha_type = ALPHA_R_BRADDR;
  1032. break;
  1033. case BFD_RELOC_ALPHA_HINT:
  1034. alpha_type = ALPHA_R_HINT;
  1035. break;
  1036. case BFD_RELOC_16_PCREL:
  1037. alpha_type = ALPHA_R_SREL16;
  1038. break;
  1039. case BFD_RELOC_32_PCREL:
  1040. alpha_type = ALPHA_R_SREL32;
  1041. break;
  1042. case BFD_RELOC_64_PCREL:
  1043. alpha_type = ALPHA_R_SREL64;
  1044. break;
  1045. default:
  1046. return (reloc_howto_type *) NULL;
  1047. }
  1048. return &alpha_howto_table[alpha_type];
  1049. }
  1050. static reloc_howto_type *
  1051. alpha_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
  1052. const char *r_name)
  1053. {
  1054. unsigned int i;
  1055. for (i = 0;
  1056. i < sizeof (alpha_howto_table) / sizeof (alpha_howto_table[0]);
  1057. i++)
  1058. if (alpha_howto_table[i].name != NULL
  1059. && strcasecmp (alpha_howto_table[i].name, r_name) == 0)
  1060. return &alpha_howto_table[i];
  1061. return NULL;
  1062. }
  1063. /* A helper routine for alpha_relocate_section which converts an
  1064. external reloc when generating relocatable output. Returns the
  1065. relocation amount. */
  1066. static bfd_vma
  1067. alpha_convert_external_reloc (bfd *output_bfd ATTRIBUTE_UNUSED,
  1068. struct bfd_link_info *info,
  1069. bfd *input_bfd,
  1070. struct external_reloc *ext_rel,
  1071. struct ecoff_link_hash_entry *h)
  1072. {
  1073. unsigned long r_symndx;
  1074. bfd_vma relocation;
  1075. BFD_ASSERT (bfd_link_relocatable (info));
  1076. if (h->root.type == bfd_link_hash_defined
  1077. || h->root.type == bfd_link_hash_defweak)
  1078. {
  1079. asection *hsec;
  1080. const char *name;
  1081. /* This symbol is defined in the output. Convert the reloc from
  1082. being against the symbol to being against the section. */
  1083. /* Clear the r_extern bit. */
  1084. ext_rel->r_bits[1] &=~ RELOC_BITS1_EXTERN_LITTLE;
  1085. /* Compute a new r_symndx value. */
  1086. hsec = h->root.u.def.section;
  1087. name = bfd_get_section_name (output_bfd, hsec->output_section);
  1088. r_symndx = (unsigned long) -1;
  1089. switch (name[1])
  1090. {
  1091. case 'A':
  1092. if (strcmp (name, "*ABS*") == 0)
  1093. r_symndx = RELOC_SECTION_ABS;
  1094. break;
  1095. case 'b':
  1096. if (strcmp (name, ".bss") == 0)
  1097. r_symndx = RELOC_SECTION_BSS;
  1098. break;
  1099. case 'd':
  1100. if (strcmp (name, ".data") == 0)
  1101. r_symndx = RELOC_SECTION_DATA;
  1102. break;
  1103. case 'f':
  1104. if (strcmp (name, ".fini") == 0)
  1105. r_symndx = RELOC_SECTION_FINI;
  1106. break;
  1107. case 'i':
  1108. if (strcmp (name, ".init") == 0)
  1109. r_symndx = RELOC_SECTION_INIT;
  1110. break;
  1111. case 'l':
  1112. if (strcmp (name, ".lita") == 0)
  1113. r_symndx = RELOC_SECTION_LITA;
  1114. else if (strcmp (name, ".lit8") == 0)
  1115. r_symndx = RELOC_SECTION_LIT8;
  1116. else if (strcmp (name, ".lit4") == 0)
  1117. r_symndx = RELOC_SECTION_LIT4;
  1118. break;
  1119. case 'p':
  1120. if (strcmp (name, ".pdata") == 0)
  1121. r_symndx = RELOC_SECTION_PDATA;
  1122. break;
  1123. case 'r':
  1124. if (strcmp (name, ".rdata") == 0)
  1125. r_symndx = RELOC_SECTION_RDATA;
  1126. else if (strcmp (name, ".rconst") == 0)
  1127. r_symndx = RELOC_SECTION_RCONST;
  1128. break;
  1129. case 's':
  1130. if (strcmp (name, ".sdata") == 0)
  1131. r_symndx = RELOC_SECTION_SDATA;
  1132. else if (strcmp (name, ".sbss") == 0)
  1133. r_symndx = RELOC_SECTION_SBSS;
  1134. break;
  1135. case 't':
  1136. if (strcmp (name, ".text") == 0)
  1137. r_symndx = RELOC_SECTION_TEXT;
  1138. break;
  1139. case 'x':
  1140. if (strcmp (name, ".xdata") == 0)
  1141. r_symndx = RELOC_SECTION_XDATA;
  1142. break;
  1143. }
  1144. if (r_symndx == (unsigned long) -1)
  1145. abort ();
  1146. /* Add the section VMA and the symbol value. */
  1147. relocation = (h->root.u.def.value
  1148. + hsec->output_section->vma
  1149. + hsec->output_offset);
  1150. }
  1151. else
  1152. {
  1153. /* Change the symndx value to the right one for
  1154. the output BFD. */
  1155. r_symndx = h->indx;
  1156. if (r_symndx == (unsigned long) -1)
  1157. {
  1158. /* Caller must give an error. */
  1159. r_symndx = 0;
  1160. }
  1161. relocation = 0;
  1162. }
  1163. /* Write out the new r_symndx value. */
  1164. H_PUT_32 (input_bfd, r_symndx, ext_rel->r_symndx);
  1165. return relocation;
  1166. }
  1167. /* Relocate a section while linking an Alpha ECOFF file. This is
  1168. quite similar to get_relocated_section_contents. Perhaps they
  1169. could be combined somehow. */
  1170. static bfd_boolean
  1171. alpha_relocate_section (bfd *output_bfd,
  1172. struct bfd_link_info *info,
  1173. bfd *input_bfd,
  1174. asection *input_section,
  1175. bfd_byte *contents,
  1176. void * external_relocs)
  1177. {
  1178. asection **symndx_to_section, *lita_sec;
  1179. struct ecoff_link_hash_entry **sym_hashes;
  1180. bfd_vma gp;
  1181. bfd_boolean gp_undefined;
  1182. bfd_vma stack[RELOC_STACKSIZE];
  1183. int tos = 0;
  1184. struct external_reloc *ext_rel;
  1185. struct external_reloc *ext_rel_end;
  1186. bfd_size_type amt;
  1187. /* We keep a table mapping the symndx found in an internal reloc to
  1188. the appropriate section. This is faster than looking up the
  1189. section by name each time. */
  1190. symndx_to_section = ecoff_data (input_bfd)->symndx_to_section;
  1191. if (symndx_to_section == (asection **) NULL)
  1192. {
  1193. amt = NUM_RELOC_SECTIONS * sizeof (asection *);
  1194. symndx_to_section = (asection **) bfd_alloc (input_bfd, amt);
  1195. if (!symndx_to_section)
  1196. return FALSE;
  1197. symndx_to_section[RELOC_SECTION_NONE] = NULL;
  1198. symndx_to_section[RELOC_SECTION_TEXT] =
  1199. bfd_get_section_by_name (input_bfd, ".text");
  1200. symndx_to_section[RELOC_SECTION_RDATA] =
  1201. bfd_get_section_by_name (input_bfd, ".rdata");
  1202. symndx_to_section[RELOC_SECTION_DATA] =
  1203. bfd_get_section_by_name (input_bfd, ".data");
  1204. symndx_to_section[RELOC_SECTION_SDATA] =
  1205. bfd_get_section_by_name (input_bfd, ".sdata");
  1206. symndx_to_section[RELOC_SECTION_SBSS] =
  1207. bfd_get_section_by_name (input_bfd, ".sbss");
  1208. symndx_to_section[RELOC_SECTION_BSS] =
  1209. bfd_get_section_by_name (input_bfd, ".bss");
  1210. symndx_to_section[RELOC_SECTION_INIT] =
  1211. bfd_get_section_by_name (input_bfd, ".init");
  1212. symndx_to_section[RELOC_SECTION_LIT8] =
  1213. bfd_get_section_by_name (input_bfd, ".lit8");
  1214. symndx_to_section[RELOC_SECTION_LIT4] =
  1215. bfd_get_section_by_name (input_bfd, ".lit4");
  1216. symndx_to_section[RELOC_SECTION_XDATA] =
  1217. bfd_get_section_by_name (input_bfd, ".xdata");
  1218. symndx_to_section[RELOC_SECTION_PDATA] =
  1219. bfd_get_section_by_name (input_bfd, ".pdata");
  1220. symndx_to_section[RELOC_SECTION_FINI] =
  1221. bfd_get_section_by_name (input_bfd, ".fini");
  1222. symndx_to_section[RELOC_SECTION_LITA] =
  1223. bfd_get_section_by_name (input_bfd, ".lita");
  1224. symndx_to_section[RELOC_SECTION_ABS] = bfd_abs_section_ptr;
  1225. symndx_to_section[RELOC_SECTION_RCONST] =
  1226. bfd_get_section_by_name (input_bfd, ".rconst");
  1227. ecoff_data (input_bfd)->symndx_to_section = symndx_to_section;
  1228. }
  1229. sym_hashes = ecoff_data (input_bfd)->sym_hashes;
  1230. /* On the Alpha, the .lita section must be addressable by the global
  1231. pointer. To support large programs, we need to allow multiple
  1232. global pointers. This works as long as each input .lita section
  1233. is <64KB big. This implies that when producing relocatable
  1234. output, the .lita section is limited to 64KB. . */
  1235. lita_sec = symndx_to_section[RELOC_SECTION_LITA];
  1236. gp = _bfd_get_gp_value (output_bfd);
  1237. if (! bfd_link_relocatable (info) && lita_sec != NULL)
  1238. {
  1239. struct ecoff_section_tdata *lita_sec_data;
  1240. /* Make sure we have a section data structure to which we can
  1241. hang on to the gp value we pick for the section. */
  1242. lita_sec_data = ecoff_section_data (input_bfd, lita_sec);
  1243. if (lita_sec_data == NULL)
  1244. {
  1245. amt = sizeof (struct ecoff_section_tdata);
  1246. lita_sec_data = ((struct ecoff_section_tdata *)
  1247. bfd_zalloc (input_bfd, amt));
  1248. lita_sec->used_by_bfd = lita_sec_data;
  1249. }
  1250. if (lita_sec_data->gp != 0)
  1251. {
  1252. /* If we already assigned a gp to this section, we better
  1253. stick with that value. */
  1254. gp = lita_sec_data->gp;
  1255. }
  1256. else
  1257. {
  1258. bfd_vma lita_vma;
  1259. bfd_size_type lita_size;
  1260. lita_vma = lita_sec->output_offset + lita_sec->output_section->vma;
  1261. lita_size = lita_sec->size;
  1262. if (gp == 0
  1263. || lita_vma < gp - 0x8000
  1264. || lita_vma + lita_size >= gp + 0x8000)
  1265. {
  1266. /* Either gp hasn't been set at all or the current gp
  1267. cannot address this .lita section. In both cases we
  1268. reset the gp to point into the "middle" of the
  1269. current input .lita section. */
  1270. if (gp && !ecoff_data (output_bfd)->issued_multiple_gp_warning)
  1271. {
  1272. (*info->callbacks->warning) (info,
  1273. _("using multiple gp values"),
  1274. (char *) NULL, output_bfd,
  1275. (asection *) NULL, (bfd_vma) 0);
  1276. ecoff_data (output_bfd)->issued_multiple_gp_warning = TRUE;
  1277. }
  1278. if (lita_vma < gp - 0x8000)
  1279. gp = lita_vma + lita_size - 0x8000;
  1280. else
  1281. gp = lita_vma + 0x8000;
  1282. }
  1283. lita_sec_data->gp = gp;
  1284. }
  1285. _bfd_set_gp_value (output_bfd, gp);
  1286. }
  1287. gp_undefined = (gp == 0);
  1288. BFD_ASSERT (bfd_header_little_endian (output_bfd));
  1289. BFD_ASSERT (bfd_header_little_endian (input_bfd));
  1290. ext_rel = (struct external_reloc *) external_relocs;
  1291. ext_rel_end = ext_rel + input_section->reloc_count;
  1292. for (; ext_rel < ext_rel_end; ext_rel++)
  1293. {
  1294. bfd_vma r_vaddr;
  1295. unsigned long r_symndx;
  1296. int r_type;
  1297. int r_extern;
  1298. int r_offset;
  1299. int r_size;
  1300. bfd_boolean relocatep;
  1301. bfd_boolean adjust_addrp;
  1302. bfd_boolean gp_usedp;
  1303. bfd_vma addend;
  1304. r_vaddr = H_GET_64 (input_bfd, ext_rel->r_vaddr);
  1305. r_symndx = H_GET_32 (input_bfd, ext_rel->r_symndx);
  1306. r_type = ((ext_rel->r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
  1307. >> RELOC_BITS0_TYPE_SH_LITTLE);
  1308. r_extern = (ext_rel->r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0;
  1309. r_offset = ((ext_rel->r_bits[1] & RELOC_BITS1_OFFSET_LITTLE)
  1310. >> RELOC_BITS1_OFFSET_SH_LITTLE);
  1311. /* Ignored the reserved bits. */
  1312. r_size = ((ext_rel->r_bits[3] & RELOC_BITS3_SIZE_LITTLE)
  1313. >> RELOC_BITS3_SIZE_SH_LITTLE);
  1314. relocatep = FALSE;
  1315. adjust_addrp = TRUE;
  1316. gp_usedp = FALSE;
  1317. addend = 0;
  1318. switch (r_type)
  1319. {
  1320. case ALPHA_R_GPRELHIGH:
  1321. (*_bfd_error_handler)
  1322. (_("%B: unsupported relocation: ALPHA_R_GPRELHIGH"),
  1323. input_bfd);
  1324. bfd_set_error (bfd_error_bad_value);
  1325. continue;
  1326. case ALPHA_R_GPRELLOW:
  1327. (*_bfd_error_handler)
  1328. (_("%B: unsupported relocation: ALPHA_R_GPRELLOW"),
  1329. input_bfd);
  1330. bfd_set_error (bfd_error_bad_value);
  1331. continue;
  1332. default:
  1333. (*_bfd_error_handler)
  1334. (_("%B: unknown relocation type %d"),
  1335. input_bfd, (int) r_type);
  1336. bfd_set_error (bfd_error_bad_value);
  1337. continue;
  1338. case ALPHA_R_IGNORE:
  1339. /* This reloc appears after a GPDISP reloc. On earlier
  1340. versions of OSF/1, It marked the position of the second
  1341. instruction to be altered by the GPDISP reloc, but it is
  1342. not otherwise used for anything. For some reason, the
  1343. address of the relocation does not appear to include the
  1344. section VMA, unlike the other relocation types. */
  1345. if (bfd_link_relocatable (info))
  1346. H_PUT_64 (input_bfd, input_section->output_offset + r_vaddr,
  1347. ext_rel->r_vaddr);
  1348. adjust_addrp = FALSE;
  1349. break;
  1350. case ALPHA_R_REFLONG:
  1351. case ALPHA_R_REFQUAD:
  1352. case ALPHA_R_HINT:
  1353. relocatep = TRUE;
  1354. break;
  1355. case ALPHA_R_BRADDR:
  1356. case ALPHA_R_SREL16:
  1357. case ALPHA_R_SREL32:
  1358. case ALPHA_R_SREL64:
  1359. if (r_extern)
  1360. addend += - (r_vaddr + 4);
  1361. relocatep = TRUE;
  1362. break;
  1363. case ALPHA_R_GPREL32:
  1364. /* This relocation is used in a switch table. It is a 32
  1365. bit offset from the current GP value. We must adjust it
  1366. by the different between the original GP value and the
  1367. current GP value. */
  1368. relocatep = TRUE;
  1369. addend = ecoff_data (input_bfd)->gp - gp;
  1370. gp_usedp = TRUE;
  1371. break;
  1372. case ALPHA_R_LITERAL:
  1373. /* This is a reference to a literal value, generally
  1374. (always?) in the .lita section. This is a 16 bit GP
  1375. relative relocation. Sometimes the subsequent reloc is a
  1376. LITUSE reloc, which indicates how this reloc is used.
  1377. This sometimes permits rewriting the two instructions
  1378. referred to by the LITERAL and the LITUSE into different
  1379. instructions which do not refer to .lita. This can save
  1380. a memory reference, and permits removing a value from
  1381. .lita thus saving GP relative space.
  1382. We do not these optimizations. To do them we would need
  1383. to arrange to link the .lita section first, so that by
  1384. the time we got here we would know the final values to
  1385. use. This would not be particularly difficult, but it is
  1386. not currently implemented. */
  1387. /* I believe that the LITERAL reloc will only apply to a ldq
  1388. or ldl instruction, so check my assumption. */
  1389. {
  1390. unsigned long insn;
  1391. insn = bfd_get_32 (input_bfd,
  1392. contents + r_vaddr - input_section->vma);
  1393. BFD_ASSERT (((insn >> 26) & 0x3f) == 0x29
  1394. || ((insn >> 26) & 0x3f) == 0x28);
  1395. }
  1396. relocatep = TRUE;
  1397. addend = ecoff_data (input_bfd)->gp - gp;
  1398. gp_usedp = TRUE;
  1399. break;
  1400. case ALPHA_R_LITUSE:
  1401. /* See ALPHA_R_LITERAL above for the uses of this reloc. It
  1402. does not cause anything to happen, itself. */
  1403. break;
  1404. case ALPHA_R_GPDISP:
  1405. /* This marks the ldah of an ldah/lda pair which loads the
  1406. gp register with the difference of the gp value and the
  1407. current location. The second of the pair is r_symndx
  1408. bytes ahead. It used to be marked with an ALPHA_R_IGNORE
  1409. reloc, but OSF/1 3.2 no longer does that. */
  1410. {
  1411. unsigned long insn1, insn2;
  1412. /* Get the two instructions. */
  1413. insn1 = bfd_get_32 (input_bfd,
  1414. contents + r_vaddr - input_section->vma);
  1415. insn2 = bfd_get_32 (input_bfd,
  1416. (contents
  1417. + r_vaddr
  1418. - input_section->vma
  1419. + r_symndx));
  1420. BFD_ASSERT (((insn1 >> 26) & 0x3f) == 0x09); /* ldah */
  1421. BFD_ASSERT (((insn2 >> 26) & 0x3f) == 0x08); /* lda */
  1422. /* Get the existing addend. We must account for the sign
  1423. extension done by lda and ldah. */
  1424. addend = ((insn1 & 0xffff) << 16) + (insn2 & 0xffff);
  1425. if (insn1 & 0x8000)
  1426. {
  1427. /* This is addend -= 0x100000000 without causing an
  1428. integer overflow on a 32 bit host. */
  1429. addend -= 0x80000000;
  1430. addend -= 0x80000000;
  1431. }
  1432. if (insn2 & 0x8000)
  1433. addend -= 0x10000;
  1434. /* The existing addend includes the difference between the
  1435. gp of the input BFD and the address in the input BFD.
  1436. We want to change this to the difference between the
  1437. final GP and the final address. */
  1438. addend += (gp
  1439. - ecoff_data (input_bfd)->gp
  1440. + input_section->vma
  1441. - (input_section->output_section->vma
  1442. + input_section->output_offset));
  1443. /* Change the instructions, accounting for the sign
  1444. extension, and write them out. */
  1445. if (addend & 0x8000)
  1446. addend += 0x10000;
  1447. insn1 = (insn1 & 0xffff0000) | ((addend >> 16) & 0xffff);
  1448. insn2 = (insn2 & 0xffff0000) | (addend & 0xffff);
  1449. bfd_put_32 (input_bfd, (bfd_vma) insn1,
  1450. contents + r_vaddr - input_section->vma);
  1451. bfd_put_32 (input_bfd, (bfd_vma) insn2,
  1452. contents + r_vaddr - input_section->vma + r_symndx);
  1453. gp_usedp = TRUE;
  1454. }
  1455. break;
  1456. case ALPHA_R_OP_PUSH:
  1457. case ALPHA_R_OP_PSUB:
  1458. case ALPHA_R_OP_PRSHIFT:
  1459. /* Manipulate values on the reloc evaluation stack. The
  1460. r_vaddr field is not an address in input_section, it is
  1461. the current value (including any addend) of the object
  1462. being used. */
  1463. if (! r_extern)
  1464. {
  1465. asection *s;
  1466. s = symndx_to_section[r_symndx];
  1467. if (s == (asection *) NULL)
  1468. abort ();
  1469. addend = s->output_section->vma + s->output_offset - s->vma;
  1470. }
  1471. else
  1472. {
  1473. struct ecoff_link_hash_entry *h;
  1474. h = sym_hashes[r_symndx];
  1475. if (h == (struct ecoff_link_hash_entry *) NULL)
  1476. abort ();
  1477. if (! bfd_link_relocatable (info))
  1478. {
  1479. if (h->root.type == bfd_link_hash_defined
  1480. || h->root.type == bfd_link_hash_defweak)
  1481. addend = (h->root.u.def.value
  1482. + h->root.u.def.section->output_section->vma
  1483. + h->root.u.def.section->output_offset);
  1484. else
  1485. {
  1486. /* Note that we pass the address as 0, since we
  1487. do not have a meaningful number for the
  1488. location within the section that is being
  1489. relocated. */
  1490. if (! ((*info->callbacks->undefined_symbol)
  1491. (info, h->root.root.string, input_bfd,
  1492. input_section, (bfd_vma) 0, TRUE)))
  1493. return FALSE;
  1494. addend = 0;
  1495. }
  1496. }
  1497. else
  1498. {
  1499. if (h->root.type != bfd_link_hash_defined
  1500. && h->root.type != bfd_link_hash_defweak
  1501. && h->indx == -1)
  1502. {
  1503. /* This symbol is not being written out. Pass
  1504. the address as 0, as with undefined_symbol,
  1505. above. */
  1506. if (! ((*info->callbacks->unattached_reloc)
  1507. (info, h->root.root.string, input_bfd,
  1508. input_section, (bfd_vma) 0)))
  1509. return FALSE;
  1510. }
  1511. addend = alpha_convert_external_reloc (output_bfd, info,
  1512. input_bfd,
  1513. ext_rel, h);
  1514. }
  1515. }
  1516. addend += r_vaddr;
  1517. if (bfd_link_relocatable (info))
  1518. {
  1519. /* Adjust r_vaddr by the addend. */
  1520. H_PUT_64 (input_bfd, addend, ext_rel->r_vaddr);
  1521. }
  1522. else
  1523. {
  1524. switch (r_type)
  1525. {
  1526. case ALPHA_R_OP_PUSH:
  1527. if (tos >= RELOC_STACKSIZE)
  1528. abort ();
  1529. stack[tos++] = addend;
  1530. break;
  1531. case ALPHA_R_OP_PSUB:
  1532. if (tos == 0)
  1533. abort ();
  1534. stack[tos - 1] -= addend;
  1535. break;
  1536. case ALPHA_R_OP_PRSHIFT:
  1537. if (tos == 0)
  1538. abort ();
  1539. stack[tos - 1] >>= addend;
  1540. break;
  1541. }
  1542. }
  1543. adjust_addrp = FALSE;
  1544. break;
  1545. case ALPHA_R_OP_STORE:
  1546. /* Store a value from the reloc stack into a bitfield. If
  1547. we are generating relocatable output, all we do is
  1548. adjust the address of the reloc. */
  1549. if (! bfd_link_relocatable (info))
  1550. {
  1551. bfd_vma mask;
  1552. bfd_vma val;
  1553. if (tos == 0)
  1554. abort ();
  1555. /* Get the relocation mask. The separate steps and the
  1556. casts to bfd_vma are attempts to avoid a bug in the
  1557. Alpha OSF 1.3 C compiler. See reloc.c for more
  1558. details. */
  1559. mask = 1;
  1560. mask <<= (bfd_vma) r_size;
  1561. mask -= 1;
  1562. /* FIXME: I don't know what kind of overflow checking,
  1563. if any, should be done here. */
  1564. val = bfd_get_64 (input_bfd,
  1565. contents + r_vaddr - input_section->vma);
  1566. val &=~ mask << (bfd_vma) r_offset;
  1567. val |= (stack[--tos] & mask) << (bfd_vma) r_offset;
  1568. bfd_put_64 (input_bfd, val,
  1569. contents + r_vaddr - input_section->vma);
  1570. }
  1571. break;
  1572. case ALPHA_R_GPVALUE:
  1573. /* I really don't know if this does the right thing. */
  1574. gp = ecoff_data (input_bfd)->gp + r_symndx;
  1575. gp_undefined = FALSE;
  1576. break;
  1577. }
  1578. if (relocatep)
  1579. {
  1580. reloc_howto_type *howto;
  1581. struct ecoff_link_hash_entry *h = NULL;
  1582. asection *s = NULL;
  1583. bfd_vma relocation;
  1584. bfd_reloc_status_type r;
  1585. /* Perform a relocation. */
  1586. howto = &alpha_howto_table[r_type];
  1587. if (r_extern)
  1588. {
  1589. h = sym_hashes[r_symndx];
  1590. /* If h is NULL, that means that there is a reloc
  1591. against an external symbol which we thought was just
  1592. a debugging symbol. This should not happen. */
  1593. if (h == (struct ecoff_link_hash_entry *) NULL)
  1594. abort ();
  1595. }
  1596. else
  1597. {
  1598. if (r_symndx >= NUM_RELOC_SECTIONS)
  1599. s = NULL;
  1600. else
  1601. s = symndx_to_section[r_symndx];
  1602. if (s == (asection *) NULL)
  1603. abort ();
  1604. }
  1605. if (bfd_link_relocatable (info))
  1606. {
  1607. /* We are generating relocatable output, and must
  1608. convert the existing reloc. */
  1609. if (r_extern)
  1610. {
  1611. if (h->root.type != bfd_link_hash_defined
  1612. && h->root.type != bfd_link_hash_defweak
  1613. && h->indx == -1)
  1614. {
  1615. /* This symbol is not being written out. */
  1616. if (! ((*info->callbacks->unattached_reloc)
  1617. (info, h->root.root.string, input_bfd,
  1618. input_section, r_vaddr - input_section->vma)))
  1619. return FALSE;
  1620. }
  1621. relocation = alpha_convert_external_reloc (output_bfd,
  1622. info,
  1623. input_bfd,
  1624. ext_rel,
  1625. h);
  1626. }
  1627. else
  1628. {
  1629. /* This is a relocation against a section. Adjust
  1630. the value by the amount the section moved. */
  1631. relocation = (s->output_section->vma
  1632. + s->output_offset
  1633. - s->vma);
  1634. }
  1635. /* If this is PC relative, the existing object file
  1636. appears to already have the reloc worked out. We
  1637. must subtract out the old value and add in the new
  1638. one. */
  1639. if (howto->pc_relative)
  1640. relocation -= (input_section->output_section->vma
  1641. + input_section->output_offset
  1642. - input_section->vma);
  1643. /* Put in any addend. */
  1644. relocation += addend;
  1645. /* Adjust the contents. */
  1646. r = _bfd_relocate_contents (howto, input_bfd, relocation,
  1647. (contents
  1648. + r_vaddr
  1649. - input_section->vma));
  1650. }
  1651. else
  1652. {
  1653. /* We are producing a final executable. */
  1654. if (r_extern)
  1655. {
  1656. /* This is a reloc against a symbol. */
  1657. if (h->root.type == bfd_link_hash_defined
  1658. || h->root.type == bfd_link_hash_defweak)
  1659. {
  1660. asection *hsec;
  1661. hsec = h->root.u.def.section;
  1662. relocation = (h->root.u.def.value
  1663. + hsec->output_section->vma
  1664. + hsec->output_offset);
  1665. }
  1666. else
  1667. {
  1668. if (! ((*info->callbacks->undefined_symbol)
  1669. (info, h->root.root.string, input_bfd,
  1670. input_section,
  1671. r_vaddr - input_section->vma, TRUE)))
  1672. return FALSE;
  1673. relocation = 0;
  1674. }
  1675. }
  1676. else
  1677. {
  1678. /* This is a reloc against a section. */
  1679. relocation = (s->output_section->vma
  1680. + s->output_offset
  1681. - s->vma);
  1682. /* Adjust a PC relative relocation by removing the
  1683. reference to the original source section. */
  1684. if (howto->pc_relative)
  1685. relocation += input_section->vma;
  1686. }
  1687. r = _bfd_final_link_relocate (howto,
  1688. input_bfd,
  1689. input_section,
  1690. contents,
  1691. r_vaddr - input_section->vma,
  1692. relocation,
  1693. addend);
  1694. }
  1695. if (r != bfd_reloc_ok)
  1696. {
  1697. switch (r)
  1698. {
  1699. default:
  1700. case bfd_reloc_outofrange:
  1701. abort ();
  1702. case bfd_reloc_overflow:
  1703. {
  1704. const char *name;
  1705. if (r_extern)
  1706. name = sym_hashes[r_symndx]->root.root.string;
  1707. else
  1708. name = bfd_section_name (input_bfd,
  1709. symndx_to_section[r_symndx]);
  1710. if (! ((*info->callbacks->reloc_overflow)
  1711. (info, NULL, name,
  1712. alpha_howto_table[r_type].name,
  1713. (bfd_vma) 0, input_bfd, input_section,
  1714. r_vaddr - input_section->vma)))
  1715. return FALSE;
  1716. }
  1717. break;
  1718. }
  1719. }
  1720. }
  1721. if (bfd_link_relocatable (info) && adjust_addrp)
  1722. {
  1723. /* Change the address of the relocation. */
  1724. H_PUT_64 (input_bfd,
  1725. (input_section->output_section->vma
  1726. + input_section->output_offset
  1727. - input_section->vma
  1728. + r_vaddr),
  1729. ext_rel->r_vaddr);
  1730. }
  1731. if (gp_usedp && gp_undefined)
  1732. {
  1733. if (! ((*info->callbacks->reloc_dangerous)
  1734. (info, _("GP relative relocation used when GP not defined"),
  1735. input_bfd, input_section, r_vaddr - input_section->vma)))
  1736. return FALSE;
  1737. /* Only give the error once per link. */
  1738. gp = 4;
  1739. _bfd_set_gp_value (output_bfd, gp);
  1740. gp_undefined = FALSE;
  1741. }
  1742. }
  1743. if (tos != 0)
  1744. abort ();
  1745. return TRUE;
  1746. }
  1747. /* Do final adjustments to the filehdr and the aouthdr. This routine
  1748. sets the dynamic bits in the file header. */
  1749. static bfd_boolean
  1750. alpha_adjust_headers (bfd *abfd,
  1751. struct internal_filehdr *fhdr,
  1752. struct internal_aouthdr *ahdr ATTRIBUTE_UNUSED)
  1753. {
  1754. if ((abfd->flags & (DYNAMIC | EXEC_P)) == (DYNAMIC | EXEC_P))
  1755. fhdr->f_flags |= F_ALPHA_CALL_SHARED;
  1756. else if ((abfd->flags & DYNAMIC) != 0)
  1757. fhdr->f_flags |= F_ALPHA_SHARABLE;
  1758. return TRUE;
  1759. }
  1760. /* Archive handling. In OSF/1 (or Digital Unix) v3.2, Digital
  1761. introduced archive packing, in which the elements in an archive are
  1762. optionally compressed using a simple dictionary scheme. We know
  1763. how to read such archives, but we don't write them. */
  1764. #define alpha_ecoff_slurp_armap _bfd_ecoff_slurp_armap
  1765. #define alpha_ecoff_slurp_extended_name_table \
  1766. _bfd_ecoff_slurp_extended_name_table
  1767. #define alpha_ecoff_construct_extended_name_table \
  1768. _bfd_ecoff_construct_extended_name_table
  1769. #define alpha_ecoff_truncate_arname _bfd_ecoff_truncate_arname
  1770. #define alpha_ecoff_write_armap _bfd_ecoff_write_armap
  1771. #define alpha_ecoff_write_ar_hdr _bfd_generic_write_ar_hdr
  1772. #define alpha_ecoff_generic_stat_arch_elt _bfd_ecoff_generic_stat_arch_elt
  1773. #define alpha_ecoff_update_armap_timestamp _bfd_ecoff_update_armap_timestamp
  1774. /* A compressed file uses this instead of ARFMAG. */
  1775. #define ARFZMAG "Z\012"
  1776. /* Read an archive header. This is like the standard routine, but it
  1777. also accepts ARFZMAG. */
  1778. static void *
  1779. alpha_ecoff_read_ar_hdr (bfd *abfd)
  1780. {
  1781. struct areltdata *ret;
  1782. struct ar_hdr *h;
  1783. ret = (struct areltdata *) _bfd_generic_read_ar_hdr_mag (abfd, ARFZMAG);
  1784. if (ret == NULL)
  1785. return NULL;
  1786. h = (struct ar_hdr *) ret->arch_header;
  1787. if (strncmp (h->ar_fmag, ARFZMAG, 2) == 0)
  1788. {
  1789. bfd_byte ab[8];
  1790. /* This is a compressed file. We must set the size correctly.
  1791. The size is the eight bytes after the dummy file header. */
  1792. if (bfd_seek (abfd, (file_ptr) FILHSZ, SEEK_CUR) != 0
  1793. || bfd_bread (ab, (bfd_size_type) 8, abfd) != 8
  1794. || bfd_seek (abfd, (file_ptr) (- (FILHSZ + 8)), SEEK_CUR) != 0)
  1795. return NULL;
  1796. ret->parsed_size = H_GET_64 (abfd, ab);
  1797. }
  1798. return ret;
  1799. }
  1800. /* Get an archive element at a specified file position. This is where
  1801. we uncompress the archive element if necessary. */
  1802. static bfd *
  1803. alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos)
  1804. {
  1805. bfd *nbfd = NULL;
  1806. struct areltdata *tdata;
  1807. struct ar_hdr *hdr;
  1808. bfd_byte ab[8];
  1809. bfd_size_type size;
  1810. bfd_byte *buf, *p;
  1811. struct bfd_in_memory *bim;
  1812. buf = NULL;
  1813. nbfd = _bfd_get_elt_at_filepos (archive, filepos);
  1814. if (nbfd == NULL)
  1815. goto error_return;
  1816. if ((nbfd->flags & BFD_IN_MEMORY) != 0)
  1817. {
  1818. /* We have already expanded this BFD. */
  1819. return nbfd;
  1820. }
  1821. tdata = (struct areltdata *) nbfd->arelt_data;
  1822. hdr = (struct ar_hdr *) tdata->arch_header;
  1823. if (strncmp (hdr->ar_fmag, ARFZMAG, 2) != 0)
  1824. return nbfd;
  1825. /* We must uncompress this element. We do this by copying it into a
  1826. memory buffer, and making bfd_bread and bfd_seek use that buffer.
  1827. This can use a lot of memory, but it's simpler than getting a
  1828. temporary file, making that work with the file descriptor caching
  1829. code, and making sure that it is deleted at all appropriate
  1830. times. It can be changed if it ever becomes important. */
  1831. /* The compressed file starts with a dummy ECOFF file header. */
  1832. if (bfd_seek (nbfd, (file_ptr) FILHSZ, SEEK_SET) != 0)
  1833. goto error_return;
  1834. /* The next eight bytes are the real file size. */
  1835. if (bfd_bread (ab, (bfd_size_type) 8, nbfd) != 8)
  1836. goto error_return;
  1837. size = H_GET_64 (nbfd, ab);
  1838. if (size != 0)
  1839. {
  1840. bfd_size_type left;
  1841. bfd_byte dict[4096];
  1842. unsigned int h;
  1843. bfd_byte b;
  1844. buf = (bfd_byte *) bfd_malloc (size);
  1845. if (buf == NULL)
  1846. goto error_return;
  1847. p = buf;
  1848. left = size;
  1849. /* I don't know what the next eight bytes are for. */
  1850. if (bfd_bread (ab, (bfd_size_type) 8, nbfd) != 8)
  1851. goto error_return;
  1852. /* This is the uncompression algorithm. It's a simple
  1853. dictionary based scheme in which each character is predicted
  1854. by a hash of the previous three characters. A control byte
  1855. indicates whether the character is predicted or whether it
  1856. appears in the input stream; each control byte manages the
  1857. next eight bytes in the output stream. */
  1858. memset (dict, 0, sizeof dict);
  1859. h = 0;
  1860. while (bfd_bread (&b, (bfd_size_type) 1, nbfd) == 1)
  1861. {
  1862. unsigned int i;
  1863. for (i = 0; i < 8; i++, b >>= 1)
  1864. {
  1865. bfd_byte n;
  1866. if ((b & 1) == 0)
  1867. n = dict[h];
  1868. else
  1869. {
  1870. if (! bfd_bread (&n, (bfd_size_type) 1, nbfd))
  1871. goto error_return;
  1872. dict[h] = n;
  1873. }
  1874. *p++ = n;
  1875. --left;
  1876. if (left == 0)
  1877. break;
  1878. h <<= 4;
  1879. h ^= n;
  1880. h &= sizeof dict - 1;
  1881. }
  1882. if (left == 0)
  1883. break;
  1884. }
  1885. }
  1886. /* Now the uncompressed file contents are in buf. */
  1887. bim = ((struct bfd_in_memory *)
  1888. bfd_malloc ((bfd_size_type) sizeof (struct bfd_in_memory)));
  1889. if (bim == NULL)
  1890. goto error_return;
  1891. bim->size = size;
  1892. bim->buffer = buf;
  1893. nbfd->mtime_set = TRUE;
  1894. nbfd->mtime = strtol (hdr->ar_date, (char **) NULL, 10);
  1895. nbfd->flags |= BFD_IN_MEMORY;
  1896. nbfd->iostream = bim;
  1897. nbfd->iovec = &_bfd_memory_iovec;
  1898. nbfd->origin = 0;
  1899. BFD_ASSERT (! nbfd->cacheable);
  1900. return nbfd;
  1901. error_return:
  1902. if (buf != NULL)
  1903. free (buf);
  1904. if (nbfd != NULL)
  1905. bfd_close (nbfd);
  1906. return NULL;
  1907. }
  1908. /* Open the next archived file. */
  1909. static bfd *
  1910. alpha_ecoff_openr_next_archived_file (bfd *archive, bfd *last_file)
  1911. {
  1912. file_ptr filestart;
  1913. if (last_file == NULL)
  1914. filestart = bfd_ardata (archive)->first_file_filepos;
  1915. else
  1916. {
  1917. struct areltdata *t;
  1918. struct ar_hdr *h;
  1919. bfd_size_type size;
  1920. /* We can't use arelt_size here, because that uses parsed_size,
  1921. which is the uncompressed size. We need the compressed size. */
  1922. t = (struct areltdata *) last_file->arelt_data;
  1923. h = (struct ar_hdr *) t->arch_header;
  1924. size = strtol (h->ar_size, (char **) NULL, 10);
  1925. /* Pad to an even boundary...
  1926. Note that last_file->origin can be odd in the case of
  1927. BSD-4.4-style element with a long odd size. */
  1928. filestart = last_file->proxy_origin + size;
  1929. filestart += filestart % 2;
  1930. }
  1931. return alpha_ecoff_get_elt_at_filepos (archive, filestart);
  1932. }
  1933. /* Open the archive file given an index into the armap. */
  1934. static bfd *
  1935. alpha_ecoff_get_elt_at_index (bfd *abfd, symindex sym_index)
  1936. {
  1937. carsym *entry;
  1938. entry = bfd_ardata (abfd)->symdefs + sym_index;
  1939. return alpha_ecoff_get_elt_at_filepos (abfd, entry->file_offset);
  1940. }
  1941. /* This is the ECOFF backend structure. The backend field of the
  1942. target vector points to this. */
  1943. static const struct ecoff_backend_data alpha_ecoff_backend_data =
  1944. {
  1945. /* COFF backend structure. */
  1946. {
  1947. (void (*) (bfd *,void *,int,int,int,int,void *)) bfd_void, /* aux_in */
  1948. (void (*) (bfd *,void *,void *)) bfd_void, /* sym_in */
  1949. (void (*) (bfd *,void *,void *)) bfd_void, /* lineno_in */
  1950. (unsigned (*) (bfd *,void *,int,int,int,int,void *)) bfd_void,/*aux_out*/
  1951. (unsigned (*) (bfd *,void *,void *)) bfd_void, /* sym_out */
  1952. (unsigned (*) (bfd *,void *,void *)) bfd_void, /* lineno_out */
  1953. (unsigned (*) (bfd *,void *,void *)) bfd_void, /* reloc_out */
  1954. alpha_ecoff_swap_filehdr_out, alpha_ecoff_swap_aouthdr_out,
  1955. alpha_ecoff_swap_scnhdr_out,
  1956. FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE,
  1957. ECOFF_NO_LONG_SECTION_NAMES, 4, FALSE, 2, 32768,
  1958. alpha_ecoff_swap_filehdr_in, alpha_ecoff_swap_aouthdr_in,
  1959. alpha_ecoff_swap_scnhdr_in, NULL,
  1960. alpha_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook,
  1961. alpha_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
  1962. _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table,
  1963. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  1964. NULL, NULL, NULL, NULL
  1965. },
  1966. /* Supported architecture. */
  1967. bfd_arch_alpha,
  1968. /* Initial portion of armap string. */
  1969. "________64",
  1970. /* The page boundary used to align sections in a demand-paged
  1971. executable file. E.g., 0x1000. */
  1972. 0x2000,
  1973. /* TRUE if the .rdata section is part of the text segment, as on the
  1974. Alpha. FALSE if .rdata is part of the data segment, as on the
  1975. MIPS. */
  1976. TRUE,
  1977. /* Bitsize of constructor entries. */
  1978. 64,
  1979. /* Reloc to use for constructor entries. */
  1980. &alpha_howto_table[ALPHA_R_REFQUAD],
  1981. {
  1982. /* Symbol table magic number. */
  1983. magicSym2,
  1984. /* Alignment of debugging information. E.g., 4. */
  1985. 8,
  1986. /* Sizes of external symbolic information. */
  1987. sizeof (struct hdr_ext),
  1988. sizeof (struct dnr_ext),
  1989. sizeof (struct pdr_ext),
  1990. sizeof (struct sym_ext),
  1991. sizeof (struct opt_ext),
  1992. sizeof (struct fdr_ext),
  1993. sizeof (struct rfd_ext),
  1994. sizeof (struct ext_ext),
  1995. /* Functions to swap in external symbolic data. */
  1996. ecoff_swap_hdr_in,
  1997. ecoff_swap_dnr_in,
  1998. ecoff_swap_pdr_in,
  1999. ecoff_swap_sym_in,
  2000. ecoff_swap_opt_in,
  2001. ecoff_swap_fdr_in,
  2002. ecoff_swap_rfd_in,
  2003. ecoff_swap_ext_in,
  2004. _bfd_ecoff_swap_tir_in,
  2005. _bfd_ecoff_swap_rndx_in,
  2006. /* Functions to swap out external symbolic data. */
  2007. ecoff_swap_hdr_out,
  2008. ecoff_swap_dnr_out,
  2009. ecoff_swap_pdr_out,
  2010. ecoff_swap_sym_out,
  2011. ecoff_swap_opt_out,
  2012. ecoff_swap_fdr_out,
  2013. ecoff_swap_rfd_out,
  2014. ecoff_swap_ext_out,
  2015. _bfd_ecoff_swap_tir_out,
  2016. _bfd_ecoff_swap_rndx_out,
  2017. /* Function to read in symbolic data. */
  2018. _bfd_ecoff_slurp_symbolic_info
  2019. },
  2020. /* External reloc size. */
  2021. RELSZ,
  2022. /* Reloc swapping functions. */
  2023. alpha_ecoff_swap_reloc_in,
  2024. alpha_ecoff_swap_reloc_out,
  2025. /* Backend reloc tweaking. */
  2026. alpha_adjust_reloc_in,
  2027. alpha_adjust_reloc_out,
  2028. /* Relocate section contents while linking. */
  2029. alpha_relocate_section,
  2030. /* Do final adjustments to filehdr and aouthdr. */
  2031. alpha_adjust_headers,
  2032. /* Read an element from an archive at a given file position. */
  2033. alpha_ecoff_get_elt_at_filepos
  2034. };
  2035. /* Looking up a reloc type is Alpha specific. */
  2036. #define _bfd_ecoff_bfd_reloc_type_lookup alpha_bfd_reloc_type_lookup
  2037. #define _bfd_ecoff_bfd_reloc_name_lookup \
  2038. alpha_bfd_reloc_name_lookup
  2039. /* So is getting relocated section contents. */
  2040. #define _bfd_ecoff_bfd_get_relocated_section_contents \
  2041. alpha_ecoff_get_relocated_section_contents
  2042. /* Handling file windows is generic. */
  2043. #define _bfd_ecoff_get_section_contents_in_window \
  2044. _bfd_generic_get_section_contents_in_window
  2045. /* Input section flag lookup is generic. */
  2046. #define _bfd_ecoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags
  2047. /* Relaxing sections is generic. */
  2048. #define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section
  2049. #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections
  2050. #define _bfd_ecoff_bfd_merge_sections bfd_generic_merge_sections
  2051. #define _bfd_ecoff_bfd_is_group_section bfd_generic_is_group_section
  2052. #define _bfd_ecoff_bfd_discard_group bfd_generic_discard_group
  2053. #define _bfd_ecoff_section_already_linked \
  2054. _bfd_coff_section_already_linked
  2055. #define _bfd_ecoff_bfd_define_common_symbol bfd_generic_define_common_symbol
  2056. const bfd_target alpha_ecoff_le_vec =
  2057. {
  2058. "ecoff-littlealpha", /* name */
  2059. bfd_target_ecoff_flavour,
  2060. BFD_ENDIAN_LITTLE, /* data byte order is little */
  2061. BFD_ENDIAN_LITTLE, /* header byte order is little */
  2062. (HAS_RELOC | EXEC_P | /* object flags */
  2063. HAS_LINENO | HAS_DEBUG |
  2064. HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
  2065. (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
  2066. 0, /* leading underscore */
  2067. ' ', /* ar_pad_char */
  2068. 15, /* ar_max_namelen */
  2069. 0, /* match priority. */
  2070. bfd_getl64, bfd_getl_signed_64, bfd_putl64,
  2071. bfd_getl32, bfd_getl_signed_32, bfd_putl32,
  2072. bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
  2073. bfd_getl64, bfd_getl_signed_64, bfd_putl64,
  2074. bfd_getl32, bfd_getl_signed_32, bfd_putl32,
  2075. bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
  2076. {_bfd_dummy_target, alpha_ecoff_object_p, /* bfd_check_format */
  2077. bfd_generic_archive_p, _bfd_dummy_target},
  2078. {bfd_false, _bfd_ecoff_mkobject, /* bfd_set_format */
  2079. _bfd_generic_mkarchive, bfd_false},
  2080. {bfd_false, _bfd_ecoff_write_object_contents, /* bfd_write_contents */
  2081. _bfd_write_archive_contents, bfd_false},
  2082. BFD_JUMP_TABLE_GENERIC (_bfd_ecoff),
  2083. BFD_JUMP_TABLE_COPY (_bfd_ecoff),
  2084. BFD_JUMP_TABLE_CORE (_bfd_nocore),
  2085. BFD_JUMP_TABLE_ARCHIVE (alpha_ecoff),
  2086. BFD_JUMP_TABLE_SYMBOLS (_bfd_ecoff),
  2087. BFD_JUMP_TABLE_RELOCS (_bfd_ecoff),
  2088. BFD_JUMP_TABLE_WRITE (_bfd_ecoff),
  2089. BFD_JUMP_TABLE_LINK (_bfd_ecoff),
  2090. BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
  2091. NULL,
  2092. & alpha_ecoff_backend_data
  2093. };