elfimage.h 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. elfimage.h
  5. Abstract:
  6. This header contains definitions for the ELF image format.
  7. Author:
  8. Evan Green 7-Mar-2014
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // --------------------------------------------------------------------- Macros
  15. //
  16. #define IS_ELF(_ElfHeader) ((_ElfHeader).e_ident[EI_MAG0] == ELFMAG0 && \
  17. (_ElfHeader).e_ident[EI_MAG1] == ELFMAG1 && \
  18. (_ElfHeader).e_ident[EI_MAG2] == ELFMAG2 && \
  19. (_ElfHeader).e_ident[EI_MAG3] == ELFMAG3)
  20. //
  21. // Define macros for accessing the fields of r_info.
  22. //
  23. #define ELF32_R_SYM(_Info) ((_Info) >> 8)
  24. #define ELF32_R_TYPE(_Info) ((unsigned char)(_Info))
  25. #define ELF64_R_SYM(_Info) ((_Info) >> 32)
  26. #define ELF64_R_TYPE(_Info) ((_Info) & 0xffffffffL)
  27. //
  28. // This macro constructs an r_info value from field values.
  29. //
  30. #define ELF32_R_INFO(_Symbol, _Type) \
  31. (((_Symbol) << 8) + (unsigned char)(_Type))
  32. #define ELF64_R_INFO(_Symbol, _Type) \
  33. (((_Symbol) << 32) + ((_Type) & 0xffffffffL))
  34. #define ELF64_R_TYPE_DATA(_Info) (((Elf64_Xword)(_Info) << 32) >> 40)
  35. #define ELF64_R_TYPE_ID(_Info) (((Elf64_Xword)(_Info) << 56) >> 56)
  36. #define ELF64_R_TYPE_INFO(_Data, _Type) \
  37. (((Elf64_Xword)(_Data) << 8) + (Elf64_Xword)(_Type))
  38. //
  39. // These macros compose and decompose values for Move.r_info.
  40. //
  41. #define ELF32_M_SYM(_Info) ((_Info) >> 8)
  42. #define ELF32_M_SIZE(_Info) ((unsigned char)(_Info))
  43. #define ELF32_M_INFO(_Symbol, _Size) (((_Symbol) << 8) + (unsigned char)(_Size))
  44. #define ELF64_M_SYM(_Info) ((_Info) >> 8)
  45. #define ELF64_M_SIZE(_Info) ((unsigned char)(_Info))
  46. #define ELF64_M_INFO(_Symbol, _Size) (((_Symbol) << 8) + (unsigned char)(_Size))
  47. //
  48. // Define macros for accessing the fields of st_info.
  49. //
  50. #define ELF32_ST_BIND(_Info) ((_Info) >> 4)
  51. #define ELF32_ST_TYPE(_Info) ((_Info) & 0xf)
  52. #define ELF64_ST_BIND(_Info) ((_Info) >> 4)
  53. #define ELF64_ST_TYPE(_Info) ((_Info) & 0xf)
  54. //
  55. // This macro constructs an st_info value from its components.
  56. //
  57. #define ELF32_ST_INFO(_Bind, _Type) (((_Bind) << 4) + ((_Type) & 0xf))
  58. #define ELF64_ST_INFO(_Bind, _Type) (((_Bind) << 4) + ((_Type) & 0xf))
  59. //
  60. // This macro accesses the visibility field of the st_other member.
  61. //
  62. #define ELF32_ST_VISIBILITY(_Other) ((_Other) & 0x3)
  63. #define ELF64_ST_VISIBILITY(_Other) ((_Other) & 0x3)
  64. //
  65. // ---------------------------------------------------------------- Definitions
  66. //
  67. //
  68. // Indexes into the e_ident array.
  69. //
  70. //
  71. // Magic numbers.
  72. //
  73. #define EI_MAG0 0
  74. #define EI_MAG1 1
  75. #define EI_MAG2 2
  76. #define EI_MAG3 3
  77. //
  78. // Class of machine
  79. //
  80. #define EI_CLASS 4
  81. //
  82. // Data format
  83. //
  84. #define EI_DATA 5
  85. //
  86. // ELF format version
  87. //
  88. #define EI_VERSION 6
  89. //
  90. // Operating system / ABI identification
  91. //
  92. #define EI_OSABI 7
  93. //
  94. // ABI version
  95. //
  96. #define EI_ABIVERSION 8
  97. //
  98. // Start of architecture identification
  99. //
  100. #define OLD_EI_BRAND 8
  101. //
  102. // Start of padding (SVR4 ABI).
  103. //
  104. #define EI_PAD 9
  105. //
  106. // Size of the e_ident array
  107. //
  108. #define EI_NIDENT 16
  109. //
  110. // Values for the magic number bytes
  111. //
  112. #define ELFMAG0 0x7f
  113. #define ELFMAG1 'E'
  114. #define ELFMAG2 'L'
  115. #define ELFMAG3 'F'
  116. #define ELFMAG "\177ELF"
  117. //
  118. // Size of the ELF magic string
  119. //
  120. #define SELFMAG 4
  121. //
  122. // Values for e_ident[EI_VERSION] and e_version
  123. //
  124. #define EV_NONE 0
  125. #define EV_CURRENT 1
  126. //
  127. // Values for e_ident[EI_CLASS]
  128. //
  129. #define ELFCLASSNONE 0
  130. #define ELFCLASS32 1
  131. #define ELFCLASS64 2
  132. //
  133. // Values for e_ident[EI_DATA]
  134. //
  135. //
  136. // Unknown data format
  137. //
  138. #define ELFDATANONE 0
  139. //
  140. // Two's complement little-endian
  141. //
  142. #define ELFDATA2LSB 1
  143. //
  144. // Two's complement big-endian
  145. //
  146. #define ELFDATA2MSB 2
  147. //
  148. // Values for e_ident[EI_OSABI]
  149. //
  150. //
  151. // UNIX System V ABI
  152. //
  153. #define ELFOSABI_NONE 0
  154. //
  155. // HP-UX operating system
  156. //
  157. #define ELFOSABI_HPUX 1
  158. //
  159. // NetBSD
  160. //
  161. #define ELFOSABI_NETBSD 2
  162. //
  163. // GNU/Linux
  164. //
  165. #define ELFOSABI_LINUX 3
  166. //
  167. // GNU/Hurd
  168. //
  169. #define ELFOSABI_HURD 4
  170. //
  171. // 86Open IA32 ABI
  172. //
  173. #define ELFOSABI_86OPEN 5
  174. //
  175. // Solaris
  176. //
  177. #define ELFOSABI_SOLARIS 6
  178. //
  179. // AIX
  180. //
  181. #define ELFOSABI_AIX 7
  182. //
  183. // IRIX
  184. //
  185. #define ELFOSABI_IRIX 8
  186. //
  187. // FreeBSD
  188. //
  189. #define ELFOSABI_FREEBSD 9
  190. //
  191. // TRU64 UNIX
  192. //
  193. #define ELFOSABI_TRU64 10
  194. //
  195. // Novell Modesto
  196. //
  197. #define ELFOSABI_MODESTO 11
  198. //
  199. // OpenBSD
  200. //
  201. #define ELFOSABI_OPENBSD 12
  202. //
  203. // Open VMS
  204. //
  205. #define ELFOSABI_OPENVMS 13
  206. //
  207. // HP Non-Stop Kernel
  208. //
  209. #define ELFOSABI_NSK 14
  210. //
  211. // ARM
  212. //
  213. #define ELFOSABI_ARM 97
  214. //
  215. // Standalone (embedded) application.
  216. //
  217. #define ELFOSABI_STANDALONE 255
  218. //
  219. // Symbol used in old spec
  220. //
  221. #define ELFOSABI_SYSV ELFOSABI_NONE
  222. //
  223. // Monterey
  224. //
  225. #define ELFOSABI_MONTEREY ELFOSABI_AIX
  226. //
  227. // Values for e_type
  228. //
  229. //
  230. // Unknown type
  231. //
  232. #define ET_NONE 0
  233. //
  234. // Relocatable
  235. //
  236. #define ET_REL 1
  237. //
  238. // Executable
  239. //
  240. #define ET_EXEC 2
  241. //
  242. // Shared object
  243. //
  244. #define ET_DYN 3
  245. //
  246. // Core file
  247. //
  248. #define ET_CORE 4
  249. //
  250. // First operating system specific value
  251. //
  252. #define ET_LOOS 0xFE00
  253. //
  254. // Last operating system specific value
  255. //
  256. #define ET_HIOS 0xFEFF
  257. //
  258. // First processor specific value
  259. //
  260. #define ET_LOPROC 0xFF00
  261. //
  262. // Last processor specific value
  263. //
  264. #define ET_HIPROC 0xFFFF
  265. //
  266. // Values for e_machine
  267. //
  268. //
  269. // Unknown machine
  270. //
  271. #define EM_NONE 0
  272. //
  273. // AT&T WE32100
  274. //
  275. #define EM_M32 1
  276. //
  277. // Sun SPARC
  278. //
  279. #define EM_SPARC 2
  280. //
  281. // Intel i386
  282. //
  283. #define EM_386 3
  284. //
  285. // Motorola 68000
  286. //
  287. #define EM_68K 4
  288. //
  289. // Motorola 88000
  290. //
  291. #define EM_88K 5
  292. //
  293. // Intel i860
  294. //
  295. #define EM_860 7
  296. //
  297. // MIPS R3000 Big-Endian
  298. //
  299. #define EM_MIPS 8
  300. //
  301. // IBM System/370
  302. //
  303. #define EM_S370 9
  304. //
  305. // MIPS R3000 Little-Endian
  306. //
  307. #define EM_MIPS_RS3_LE 10
  308. //
  309. // HP PA-RISC
  310. //
  311. #define EM_PARISC 15
  312. //
  313. // Fujistsu VPP500
  314. //
  315. #define EM_VPP500 17
  316. //
  317. // SPARC v8plus
  318. //
  319. #define EM_SPARC32PLUS 18
  320. //
  321. // Intel 80960
  322. //
  323. #define EM_960 19
  324. //
  325. // PowerPC 32-bit
  326. //
  327. #define EM_PPC 20
  328. //
  329. // PowerPC 64-bit
  330. //
  331. #define EM_PPC64 21
  332. //
  333. // IBM System/390
  334. //
  335. #define EM_S390 22
  336. //
  337. // NEC V800
  338. //
  339. #define EM_V800 36
  340. //
  341. // Fujitsu FR20
  342. //
  343. #define EM_FR20 37
  344. //
  345. // TRW RH-32
  346. //
  347. #define EM_RH32 38
  348. //
  349. // Motorola RCE
  350. //
  351. #define EM_RCE 39
  352. //
  353. // ARM
  354. //
  355. #define EM_ARM 40
  356. //
  357. // Hitachi SH
  358. //
  359. #define EM_SH 42
  360. //
  361. // Sparc v9 64-bit
  362. //
  363. #define EM_SPARCV9 43
  364. //
  365. // Siemens TriCore embedded processor
  366. //
  367. #define EM_TRICORE 44
  368. //
  369. // Argonaut RISC Core
  370. //
  371. #define EM_ARC 45
  372. //
  373. // Hitachi H8/300
  374. //
  375. #define EM_H8_300 46
  376. //
  377. // Hitachi H8/300H
  378. //
  379. #define EM_H8_300H 47
  380. //
  381. // Hitachi H8S
  382. //
  383. #define EM_H8S 48
  384. //
  385. // Hitachi H8/500
  386. //
  387. #define EM_H8_500 49
  388. //
  389. // Intel IA64
  390. //
  391. #define EM_IA_64 50
  392. //
  393. // Stanford MIPS-X
  394. //
  395. #define EM_MIPS_X 51
  396. //
  397. // Motorola ColdFire
  398. //
  399. #define EM_COLDFIRE 52
  400. //
  401. // Motorola M68HC12
  402. //
  403. #define EM_68HC12 53
  404. //
  405. // Fujitsu MMA
  406. //
  407. #define EM_MMA 54
  408. //
  409. // Siemens PCP
  410. //
  411. #define EM_PCP 55
  412. //
  413. // Sony nCPU
  414. //
  415. #define EM_NCPU 56
  416. //
  417. // Denso NDR1 microprocessor
  418. //
  419. #define EM_NDR1 57
  420. //
  421. // Motorola Star*Core processor
  422. //
  423. #define EM_STARCORE 58
  424. //
  425. // Toyota ME16 processor
  426. //
  427. #define EM_ME16 59
  428. //
  429. // STMicroelectronics ST100 processor
  430. //
  431. #define EM_ST100 60
  432. //
  433. // Advanced Logic Corp. TinyJ processor
  434. //
  435. #define EM_TINYJ 61
  436. //
  437. // AMD x86-64
  438. //
  439. #define EM_X86_64 62
  440. //
  441. // AMD x86-64 (compat)
  442. //
  443. #define EM_AMD64 EM_X86_64
  444. //
  445. // ARM 64 bit architecture
  446. //
  447. #define EM_AARCH64 183
  448. //
  449. // Non-standard or deprecated values
  450. //
  451. //
  452. // Intel i486
  453. //
  454. #define EM_486 6
  455. //
  456. // MIPS R4000 Big-Endian
  457. //
  458. #define EM_MIPS_RS4_BE 10
  459. //
  460. // Digital Alpha (standard value)
  461. //
  462. #define EM_ALPHA_STD 41
  463. //
  464. // Alpha
  465. //
  466. #define EM_ALPHA 0x9026
  467. //
  468. // Special section indices
  469. //
  470. //
  471. // Undefined, missing, or irrelevant
  472. //
  473. #define SHN_UNDEF 0
  474. //
  475. // First of the reserved range
  476. //
  477. #define SHN_LORESERVE 0xff00
  478. //
  479. // First processor specific
  480. //
  481. #define SHN_LOPROC 0xff00
  482. //
  483. // Last processor specific
  484. //
  485. #define SHN_HIPROC 0xff1f
  486. //
  487. // First operating system specific
  488. //
  489. #define SHN_LOOS 0xff20
  490. //
  491. // Last operating system specific
  492. //
  493. #define SHN_HIOS 0xff3f
  494. //
  495. // Absolute values
  496. //
  497. #define SHN_ABS 0xfff1
  498. //
  499. // Common data
  500. //
  501. #define SHN_COMMON 0xfff2
  502. //
  503. // Escape, the index is stored elsewhere
  504. //
  505. #define SHN_XINDEX 0xffff
  506. //
  507. // Last of the reserved range
  508. //
  509. #define SHN_HIRESERVE 0xffff
  510. //
  511. // sh_type values
  512. //
  513. //
  514. // Inactive
  515. //
  516. #define SHT_NULL 0
  517. //
  518. // Program defined information
  519. //
  520. #define SHT_PROGBITS 1
  521. //
  522. // Symbol table section
  523. //
  524. #define SHT_SYMTAB 2
  525. //
  526. // String table section
  527. //
  528. #define SHT_STRTAB 3
  529. //
  530. // Relocation section with addends
  531. //
  532. #define SHT_RELA 4
  533. //
  534. // Symbol hash table section
  535. //
  536. #define SHT_HASH 5
  537. //
  538. // Dynamic section
  539. //
  540. #define SHT_DYNAMIC 6
  541. //
  542. // Note section
  543. //
  544. #define SHT_NOTE 7
  545. //
  546. // No-space section
  547. //
  548. #define SHT_NOBITS 8
  549. //
  550. // Relocation section, no addends
  551. //
  552. #define SHT_REL 9
  553. //
  554. // Reserved, purpose unknown
  555. //
  556. #define SHT_SHLIB 10
  557. //
  558. // Dynamic symbol table section
  559. //
  560. #define SHT_DYNSYM 11
  561. //
  562. // Initialization function pointers
  563. //
  564. #define SHT_INIT_ARRAY 14
  565. //
  566. // Termination function pointers
  567. //
  568. #define SHT_FINI_ARRAY 15
  569. //
  570. // Pre-initialization function pointers
  571. //
  572. #define SHT_PREINIT_ARRAY 16
  573. //
  574. // Section group
  575. //
  576. #define SHT_GROUP 17
  577. //
  578. // Section indices
  579. //
  580. #define SHT_SYMTAB_SHNDX 18
  581. //
  582. // First of OS specific semantic values
  583. //
  584. #define SHT_LOOS 0x60000000
  585. #define SHT_LOSUNW 0x6ffffff4
  586. #define SHT_SUNW_dof 0x6ffffff4
  587. #define SHT_SUNW_cap 0x6ffffff5
  588. #define SHT_SUNW_SIGNATURE 0x6ffffff6
  589. #define SHT_SUNW_ANNOTATE 0x6ffffff7
  590. #define SHT_SUNW_DEBUGSTR 0x6ffffff8
  591. #define SHT_SUNW_DEBUG 0x6ffffff9
  592. #define SHT_SUNW_move 0x6ffffffa
  593. #define SHT_SUNW_COMDAT 0x6ffffffb
  594. #define SHT_SUNW_syminfo 0x6ffffffc
  595. #define SHT_SUNW_verdef 0x6ffffffd
  596. #define SHT_GNU_verdef 0x6ffffffd
  597. #define SHT_SUNW_verneed 0x6ffffffe
  598. #define SHT_GNU_verneed 0x6ffffffe
  599. #define SHT_SUNW_versym 0x6fffffff
  600. #define SHT_GNU_versym 0x6fffffff
  601. #define SHT_HISUNW 0x6fffffff
  602. //
  603. // Last of OS specific semantic values
  604. //
  605. #define SHT_HIOS 0x6fffffff
  606. //
  607. // Reserved range for processor
  608. //
  609. #define SHT_LOPROC 0x70000000
  610. //
  611. // Unwind information
  612. //
  613. #define SHT_AMD64_UNWIND 0x70000001
  614. //
  615. // Specific section header types
  616. //
  617. #define SHT_HIPROC 0x7fffffff
  618. //
  619. // Reserved range for applications
  620. //
  621. #define SHT_LOUSER 0x80000000
  622. //
  623. // Specific indices
  624. //
  625. #define SHT_HIUSER 0xffffffff
  626. //
  627. // Flags for sh_flags
  628. //
  629. //
  630. // Section contains writable data
  631. //
  632. #define SHF_WRITE 0x1
  633. //
  634. // Section occupies memory
  635. //
  636. #define SHF_ALLOC 0x2
  637. //
  638. // Section contains instructions
  639. //
  640. #define SHF_EXECINSTR 0x4
  641. //
  642. // Section may be merged
  643. //
  644. #define SHF_MERGE 0x10
  645. //
  646. // Section contains strings
  647. //
  648. #define SHF_STRINGS 0x20
  649. //
  650. // sh_info holds the section index
  651. //
  652. #define SHF_INFO_LINK 0x40
  653. //
  654. // Special ordering requirements
  655. //
  656. #define SHF_LINK_ORDER 0x80
  657. //
  658. // OS-specific processing required
  659. //
  660. #define SHF_OS_NONCONFORMING 0x100
  661. //
  662. // Member of section grup
  663. //
  664. #define SHF_GROUP 0x200
  665. //
  666. // Section contains Thread Local Storage data
  667. //
  668. #define SHF_TLS 0x400
  669. //
  670. // OS-specific semantics
  671. //
  672. #define SHF_MASKOS 0x0ff00000
  673. //
  674. // Processor-specific semantics
  675. //
  676. #define SHF_MASKPROC 0xf0000000
  677. //
  678. // Values for p_type
  679. //
  680. //
  681. // Unused entry
  682. //
  683. #define PT_NULL 0
  684. //
  685. // Loadable segment
  686. //
  687. #define PT_LOAD 1
  688. //
  689. // Dynamic linking information segment
  690. //
  691. #define PT_DYNAMIC 2
  692. //
  693. // Pathname of interpreter
  694. //
  695. #define PT_INTERP 3
  696. //
  697. // Auxiliary information
  698. //
  699. #define PT_NOTE 4
  700. //
  701. // Reserved (not used)
  702. //
  703. #define PT_SHLIB 5
  704. //
  705. // Location of the program header
  706. //
  707. #define PT_PHDR 6
  708. //
  709. // Thread Local Storage segment
  710. //
  711. #define PT_TLS 7
  712. //
  713. // First OS-specific value
  714. //
  715. #define PT_LOOS 0x60000000
  716. //
  717. // AMD64 unwind program header
  718. //
  719. #define PT_SUNW_UNWIND 0x6464e550
  720. #define PT_GNU_EH_FRAME 0x6474e550
  721. #define PT_LOSUNW 0x6ffffffa
  722. //
  723. // Sun-specific segment
  724. //
  725. #define PT_SUNWBSS 0x6ffffffa
  726. //
  727. // Describes the stack segment
  728. //
  729. #define PT_SUNWSTACK 0x6ffffffb
  730. //
  731. // Private
  732. //
  733. #define PT_SUNWDTRACE 0x6ffffffc
  734. //
  735. // Hard/soft capabilities segment
  736. //
  737. #define PT_SUNWCAP 0x6ffffffd
  738. #define PT_HISUNW 0x6fffffff
  739. //
  740. // Last OS-specific value
  741. //
  742. #define PT_HIOS 0x6fffffff
  743. //
  744. // Processor-specific types
  745. //
  746. #define PT_LOPROC 0x70000000
  747. #define PT_HIPROC 0x7fffffff
  748. //
  749. // Values for p_flags: executable, readable, writable.
  750. //
  751. #define PF_X 0x1
  752. #define PF_W 0x2
  753. #define PF_R 0x4
  754. #define PF_MASKOS 0x0ff00000
  755. #define PF_MASKPROC 0xf0000000
  756. //
  757. // Extended program header index
  758. //
  759. #define PN_XNUM 0xffff
  760. //
  761. // Values for d_tag
  762. //
  763. //
  764. // Terminating entry
  765. //
  766. #define DT_NULL 0
  767. //
  768. // String table offset of a needed shared library
  769. //
  770. #define DT_NEEDED 1
  771. //
  772. // Total size in bytes of PLT relocations
  773. //
  774. #define DT_PLTRELSZ 2
  775. //
  776. // Processor-dependent entries
  777. //
  778. #define DT_PLTGOT 3
  779. //
  780. // Address of symbol hash table
  781. //
  782. #define DT_HASH 4
  783. //
  784. // Address of string table
  785. //
  786. #define DT_STRTAB 5
  787. //
  788. // Address of symbol table
  789. //
  790. #define DT_SYMTAB 6
  791. //
  792. // Address of ElfNN_Rela relocations
  793. //
  794. #define DT_RELA 7
  795. //
  796. // Total size of ElfNN_rela relocations
  797. //
  798. #define DT_RELASZ 8
  799. //
  800. // Size of each ElfNN_Rela relocation entry
  801. //
  802. #define DT_RELAENT 9
  803. //
  804. // Size of each string table
  805. //
  806. #define DT_STRSZ 10
  807. //
  808. // Size of each symbol table entry
  809. //
  810. #define DT_SYMENT 11
  811. //
  812. // Address of initialization function
  813. //
  814. #define DT_INIT 12
  815. //
  816. // Address of finalization function
  817. //
  818. #define DT_FINI 13
  819. //
  820. // String table offset of a shared object name
  821. //
  822. #define DT_SONAME 14
  823. //
  824. // String table offset of a library path
  825. //
  826. #define DT_RPATH 15
  827. //
  828. // Indicates "symbolic" linking.
  829. //
  830. #define DT_SYMBOLIC 16
  831. //
  832. // Address of ElfNN_Rel relocations
  833. //
  834. #define DT_REL 17
  835. //
  836. // Total size of ElfNN_Rel relocations
  837. //
  838. #define DT_RELSZ 18
  839. //
  840. // Size of each ElfNN_Rel relocation
  841. //
  842. #define DT_RELENT 19
  843. //
  844. // Type of relocation used for PLT
  845. //
  846. #define DT_PLTREL 20
  847. //
  848. // Reserved (not used).
  849. //
  850. #define DT_DEBUG 21
  851. //
  852. // Indicates there may be relocations in non-writable segments
  853. //
  854. #define DT_TEXTREL 22
  855. //
  856. // Address of PLT relocations
  857. //
  858. #define DT_JMPREL 23
  859. #define DT_BIND_NOW 24
  860. //
  861. // Address of the array of pointers to initialization functions
  862. //
  863. #define DT_INIT_ARRAY 25
  864. //
  865. // Address of the array of pointers to termination functions
  866. //
  867. #define DT_FINI_ARRAY 26
  868. //
  869. // Size in bytes of the array of initialization functions
  870. //
  871. #define DT_INIT_ARRAYSZ 27
  872. //
  873. // Size in bytes of the array of termination functions
  874. //
  875. #define DT_FINI_ARRAYSZ 28
  876. //
  877. // String table offset of a null-terminated library search path string
  878. //
  879. #define DT_RUNPATH 29
  880. //
  881. // Object specific flag values
  882. //
  883. #define DT_FLAGS 30
  884. #define DT_ENCODING 32
  885. //
  886. // Address of the array of pointers to pre-initialization functions
  887. //
  888. #define DT_PREINIT_ARRAY 32
  889. //
  890. // Size in bytes of the array of pre-initialization functions
  891. //
  892. #define DT_PREINIT_ARRAYSZ 33
  893. //
  894. // Number of positive tags
  895. //
  896. #define DT_MAXPOSTAGS 34
  897. //
  898. // First OS-specific value
  899. //
  900. #define DT_LOOS 0x6000000d
  901. //
  902. // Symbol auxiliary name
  903. //
  904. #define DT_SUNW_AUXILIARY 0x6000000d
  905. //
  906. // ld.so.1 info (private)
  907. //
  908. #define DT_SUNW_RTLDINF 0x6000000e
  909. //
  910. // Symbol filter name
  911. //
  912. #define DT_SUNW_FILTER 0x6000000f
  913. //
  914. // Hardware/software
  915. //
  916. #define DT_SUNW_CAP 0x60000010
  917. //
  918. // Last OS-specific
  919. //
  920. #define DT_HIOS 0x6ffff000
  921. //
  922. // DT_* entries which fall between DT_VALRNGHI and DT_VALRNGLO use the
  923. // Dyn.d_un_d_val fields of the Elf*_Dyn structure.
  924. //
  925. #define DT_VALRNGLO 0x6ffffd00
  926. //
  927. // ELF checksum
  928. //
  929. #define DT_CHECKSUM 0x6ffffdf8
  930. //
  931. // PLT padding size
  932. //
  933. #define DT_PLTPADSZ 0x6ffffdf9
  934. //
  935. // Move table entry size
  936. //
  937. #define DT_MOVEENT 0x6ffffdfa
  938. //
  939. // Move table size
  940. //
  941. #define DT_MOVESZ 0x6ffffdfb
  942. //
  943. // Feature holder
  944. //
  945. #define DT_FEATURE_1 0x6ffffdfc
  946. //
  947. // Flags for DT_* entries.
  948. //
  949. #define DT_POSFLAG_1 0x6ffffdfd
  950. //
  951. // Syminfo table size (in bytes)
  952. //
  953. #define DT_SYMINSZ 0x6ffffdfe
  954. //
  955. // Syminfo entry size (in bytes)
  956. //
  957. #define DT_SYMINENT 0x6ffffdff
  958. #define DT_VALRNGHI 0x6ffffdff
  959. //
  960. // DT_* entries which fall between DT_ADDRRNGHI and DT_ADDRRNGLO use the
  961. // Dyn.d_un.d_ptr field of the Elf*_Dyn structure. If any adjustment is made
  962. // to the ELF object after it has been build, these entries will need to be
  963. // adjusted.
  964. //
  965. #define DT_ADDRRNGLO 0x6ffffe00
  966. //
  967. // Configuration information
  968. //
  969. #define DT_CONFIG 0x6ffffefa
  970. //
  971. // Dependency auditing
  972. //
  973. #define DT_DEPAUDIT 0x6ffffefb
  974. //
  975. // Object auditing
  976. //
  977. #define DT_AUDIT 0x6ffffefc
  978. //
  979. // PLT padding (sparcv9)
  980. //
  981. #define DT_PLTPAD 0x6ffffefd
  982. //
  983. // Move table
  984. //
  985. #define DT_MOVETAB 0x6ffffefe
  986. //
  987. // Syminfo table
  988. //
  989. #define DT_SYMINFO 0x6ffffeff
  990. #define DT_ADDRRNGHI 0x6ffffeff
  991. //
  992. // Address of versym section
  993. //
  994. #define DT_VERSYM 0x6ffffff0
  995. //
  996. // Number of RELATIVE relocations
  997. //
  998. #define DT_RELACOUNT 0x6ffffff9
  999. #define DT_RELCOUNT 0x6ffffffa
  1000. //
  1001. // State flags. See DF_1_* definitions
  1002. //
  1003. #define DT_FLAGS_1 0x6ffffffb
  1004. //
  1005. // Address of verdef section
  1006. //
  1007. #define DT_VERDEF 0x6ffffffc
  1008. //
  1009. // Number of elements in the verdef section
  1010. //
  1011. #define DT_VERDEFNUM 0x6ffffffd
  1012. //
  1013. // Address of verneed section
  1014. //
  1015. #define DT_VERNEED 0x6ffffffe
  1016. //
  1017. // Number of elements in the verneed section
  1018. //
  1019. #define DT_VERNEEDNUM 0x6fffffff
  1020. //
  1021. // Processor-specific range
  1022. //
  1023. #define DT_LOPROC 0x70000000
  1024. #define DT_DEPRECATED_SPARC_REGISTER 0x7000001
  1025. //
  1026. // Shared library auxiliary name
  1027. //
  1028. #define DT_AUXILIARY 0x7ffffffd
  1029. //
  1030. // Ignored, same as needed
  1031. //
  1032. #define DT_USED 0x7ffffffe
  1033. //
  1034. // Shared library filter name
  1035. //
  1036. #define DT_FILTER 0x7fffffff
  1037. #define DT_HIPROC 0x7fffffff
  1038. //
  1039. // Values for DT_FLAGS
  1040. //
  1041. //
  1042. // Indicates that the object being loaded may make reference to the $ORIGIN
  1043. // substitution string.
  1044. //
  1045. #define DF_ORIGIN 0x0001
  1046. //
  1047. // Indicates "symbolic" linking
  1048. //
  1049. #define DF_SYMBOLIC 0x0002
  1050. //
  1051. // Indicates there may be relocations in non-writable segments
  1052. //
  1053. #define DF_TEXTREL 0x0004
  1054. //
  1055. // Indicates that the dynamic linker should process all relocations for the
  1056. // object containing this entry before transferring control to the program
  1057. //
  1058. #define DF_BIND_NOW 0x0008
  1059. //
  1060. // Indicates that the shared object or executable contains code using a static
  1061. // thread-local storage scheme
  1062. //
  1063. #define DF_STATIC_TLS 0x0010
  1064. //
  1065. // Values for n_type. Used in core files.
  1066. //
  1067. //
  1068. // Process status
  1069. //
  1070. #define NT_PRSTATUS 1
  1071. //
  1072. // Floating point registers
  1073. //
  1074. #define NT_FPREGSET 2
  1075. //
  1076. // Process state info
  1077. //
  1078. #define NT_PRPSINFO 3
  1079. //
  1080. // Symbol Binding, ELFNN_ST_BIND - st_info
  1081. //
  1082. //
  1083. // Local symbol
  1084. //
  1085. #define STB_LOCAL 0
  1086. //
  1087. // Global symbol
  1088. //
  1089. #define STB_GLOBAL 1
  1090. //
  1091. // Global symbol with a lower precedence
  1092. //
  1093. #define STB_WEAK 2
  1094. //
  1095. // OS specific range
  1096. //
  1097. #define STB_LOOS 10
  1098. #define STB_HIOS 12
  1099. //
  1100. // Processor specific range
  1101. //
  1102. #define STB_LOPROC 13
  1103. #define STB_HIPROC 15
  1104. //
  1105. // Symbol type - ELFNN_ST_TYPE - st_info
  1106. //
  1107. //
  1108. // Unspecified type
  1109. //
  1110. #define STT_NOTYPE 0
  1111. //
  1112. // Data object
  1113. //
  1114. #define STT_OBJECT 1
  1115. //
  1116. // Function
  1117. //
  1118. #define STT_FUNC 2
  1119. //
  1120. // Section
  1121. //
  1122. #define STT_SECTION 3
  1123. //
  1124. // Source file
  1125. //
  1126. #define STT_FILE 4
  1127. //
  1128. // Uninitialized common block
  1129. //
  1130. #define STT_COMMON 5
  1131. //
  1132. // Thread local storage object
  1133. //
  1134. #define STT_TLS 6
  1135. #define STT_NUM 7
  1136. //
  1137. // OS-specific range
  1138. //
  1139. #define STT_LOOS 10
  1140. #define STT_HIOS 12
  1141. //
  1142. // Processor-specific range
  1143. //
  1144. #define STT_LOPROC 13
  1145. #define STT_HIPROC 15
  1146. //
  1147. // Symbol visibility - ELFNN_ST_VISIBILITY - st_other
  1148. //
  1149. //
  1150. // Default visibility (see binding)
  1151. //
  1152. #define STV_DEFAULT 0x0
  1153. //
  1154. // Special meaning in relocatable objects
  1155. //
  1156. #define STV_INTERNAL 0x1
  1157. //
  1158. // Not visible
  1159. //
  1160. #define STV_HIDDEN 0x2
  1161. //
  1162. // Visible but not preemptible
  1163. //
  1164. #define STV_PROTECTED 0x3
  1165. //
  1166. // Special symbol table indices - Undefined symbol index
  1167. //
  1168. #define STN_UNDEF 0
  1169. #define VER_DEF_CURRENT 1
  1170. #define VER_DEF_IDX(x) VER_NDX(x)
  1171. #define VER_FLG_BASE 0x01
  1172. #define VER_FLG_WEAK 0x02
  1173. #define VER_NEED_CURRENT 1
  1174. #define VER_NEED_WEAK (1u << 15)
  1175. #define VER_NEED_HIDDEN VER_NDX_HIDDEN
  1176. #define VER_NEED_IDX(x) VER_NDX(x)
  1177. #define VER_NDX_LOCAL 0
  1178. #define VER_NDX_GLOBAL 1
  1179. #define VER_NDX_GIVEN 2
  1180. #define VER_NDX_HIDDEN (1u << 15)
  1181. #define VER_NDX(x) ((x) & ~(1u << 15))
  1182. #define CA_SUNW_NULL 0
  1183. //
  1184. // First hardware capabilities array
  1185. //
  1186. #define CA_SUNW_HW_1 1
  1187. //
  1188. // First software capabilities array
  1189. //
  1190. #define CA_SUNW_SF_1 2
  1191. //
  1192. // Syminfo flag values
  1193. //
  1194. //
  1195. // The symbol reference has direc association with an object containing a
  1196. // definition.
  1197. //
  1198. #define SYMINFO_FLG_DIRECT 0x0001
  1199. //
  1200. // Ignored, see SYMINFO_FLG_FILTER
  1201. //
  1202. #define SYMINFO_FLG_PASSTHRU 0x0002
  1203. //
  1204. // The symbol is a copy-reloc
  1205. //
  1206. #define SYMINFO_FLG_COPY 0x0004
  1207. //
  1208. // The object containing definition should be lazily loaded.
  1209. //
  1210. #define SYMINFO_FLG_LAZYLOAD 0x0008
  1211. //
  1212. // The reference should be found directly to the object containing the
  1213. // definition.
  1214. //
  1215. #define SYMINFO_FLG_DIRECTBIND 0x0010
  1216. //
  1217. // Don't let an external reference directly bind to this symbol.
  1218. //
  1219. #define SYMINFO_FLG_NOEXTDIRECT 0x0020
  1220. //
  1221. // The symbol reference is associated to a standard or auxiliary filter.
  1222. //
  1223. #define SYMINFO_FLG_FILTER 0x0002
  1224. #define SYMINFO_FLG_AUXILIARY 0x0040
  1225. //
  1226. // Syminfo.si_boundto values
  1227. //
  1228. //
  1229. // The symbol is bound to itself.
  1230. //
  1231. #define SYMINFO_BT_SELF 0xffff
  1232. //
  1233. // The symbol is bound to its parent.
  1234. //
  1235. #define SYMINFO_BT_PARENT 0xfffe
  1236. //
  1237. // The symbol has no special symbol binding
  1238. //
  1239. #define SYMINFO_BT_NONE 0xfffd
  1240. //
  1241. // The symbol is defined as external
  1242. //
  1243. #define SYMINFO_BT_EXTERN 0xfffc
  1244. //
  1245. // Reserved entries
  1246. //
  1247. #define SYMINFO_BT_LOWRESERVE 0xff00
  1248. //
  1249. // Syminfo version values
  1250. //
  1251. #define SYMINFO_NONE 0
  1252. #define SYMINFO_CURRENT 1
  1253. #define SYMINFO_NUM 2
  1254. //
  1255. // Relocation types
  1256. // All machine architectures are defined here to allow tools on one to handle
  1257. // others.
  1258. //
  1259. //
  1260. // No relocation
  1261. //
  1262. #define R_386_NONE 0
  1263. //
  1264. // Add symbol value
  1265. //
  1266. #define R_386_32 1
  1267. //
  1268. // Add PC-relative symbol value
  1269. //
  1270. #define R_386_PC32 2
  1271. //
  1272. // Add PC-relative GOT offset
  1273. //
  1274. #define R_386_GOT32 3
  1275. //
  1276. // Add PC-relative PLT offset
  1277. //
  1278. #define R_386_PLT32 4
  1279. //
  1280. // Copy data from the shared object
  1281. //
  1282. #define R_386_COPY 5
  1283. //
  1284. // Set GOT entry to data address
  1285. //
  1286. #define R_386_GLOB_DAT 6
  1287. //
  1288. // Set GOT entry to code address
  1289. //
  1290. #define R_386_JMP_SLOT 7
  1291. //
  1292. // Add load address of shared object
  1293. //
  1294. #define R_386_RELATIVE 8
  1295. //
  1296. // Add GOT-relative symbol address
  1297. //
  1298. #define R_386_GOTOFF 9
  1299. //
  1300. // Add PC-relative GOT table address
  1301. //
  1302. #define R_386_GOTPC 10
  1303. //
  1304. // Negative offset in static TLS block
  1305. //
  1306. #define R_386_TLS_TPOFF 14
  1307. //
  1308. // Absolute address of GOT for -ve static TLS
  1309. //
  1310. #define R_386_TLS_IE 15
  1311. //
  1312. // GOT entry for negative static TLS block
  1313. //
  1314. #define R_386_TLS_GOTIE 16
  1315. //
  1316. // Negative offset relative to static TLD
  1317. //
  1318. #define R_386_TLS_LE 17
  1319. //
  1320. // 32-bit offset to GOT (index, offset) pair
  1321. //
  1322. #define R_386_TLS_GD 18
  1323. //
  1324. // 32-bit offset to GOT (index, zero) pair
  1325. //
  1326. #define R_386_TLS_LDM 19
  1327. //
  1328. // 32-bit offset to GOT (index, offset) pair
  1329. //
  1330. #define R_386_TLS_GD_32 24
  1331. //
  1332. // Pushl instruction for Sun ABI GD sequence
  1333. //
  1334. #define R_386_TLS_GD_PUSH 25
  1335. //
  1336. // Call instruction for Sun ABI GD sequence
  1337. //
  1338. #define R_386_TLS_GD_CALL 26
  1339. //
  1340. // Popl instruction for Sun ABI GD sequence
  1341. //
  1342. #define R_386_TLS_GD_POP 27
  1343. //
  1344. // 32-bit offset to GOT (index, zero) pair
  1345. //
  1346. #define R_386_TLS_LDM_32 28
  1347. //
  1348. // Pushl instruction for Sun ABI LD sequence
  1349. //
  1350. #define R_386_TLS_LDM_PUSH 29
  1351. //
  1352. // Call instruction for Sun ABI LD sequence
  1353. //
  1354. #define R_386_TLS_LDM_CALL 30
  1355. //
  1356. // Popl instruction for Sun ABI LD sequence
  1357. //
  1358. #define R_386_TLS_LDM_POP 31
  1359. //
  1360. // 32-bit offset from start of TLS block
  1361. //
  1362. #define R_386_TLS_LDO_32 32
  1363. //
  1364. // 32-bit offset to GOT static TLS offset entry
  1365. //
  1366. #define R_386_TLS_IE_32 33
  1367. //
  1368. // 32-bit offset within static TLS block
  1369. //
  1370. #define R_386_TLS_LE_32 34
  1371. //
  1372. // GOT entry containing TLS index
  1373. //
  1374. #define R_386_TLS_DTPMOD32 35
  1375. //
  1376. // GOT entry containing TLS offset
  1377. //
  1378. #define R_386_TLS_DTPOFF32 36
  1379. //
  1380. // GOT entry of -ve static TLS offset
  1381. //
  1382. #define R_386_TLS_TPOFF32 37
  1383. //
  1384. // AArch64 relocations
  1385. //
  1386. //
  1387. // No relocation
  1388. //
  1389. #define R_AARCH64_NONE 256
  1390. //
  1391. // Static AArch64 relocations
  1392. //
  1393. //
  1394. // S + A
  1395. //
  1396. #define R_AARCH64_ABS64 257
  1397. #define R_AARCH64_ABS32 258
  1398. #define R_AARCH64_ABS16 259
  1399. //
  1400. // S + A - P
  1401. //
  1402. #define R_AARCH64_PREL64 260
  1403. #define R_AARCH64_PREL32 261
  1404. #define R_AARCH64_PREL16 262
  1405. //
  1406. // Group relocations to create a 16, 32, 48, or 64 bit unsigned ata value
  1407. // or address inline.
  1408. // S + A
  1409. //
  1410. #define R_AARCH64_MOVW_UABS_G0 263
  1411. #define R_AARCH64_MOVW_UABS_G0_NC 264
  1412. #define R_AARCH64_MOVW_UABS_G1 265
  1413. #define R_AARCH64_MOVW_UABS_G1_NC 266
  1414. #define R_AARCH64_MOVW_UABS_G2 267
  1415. #define R_AARCH64_MOVW_UABS_G2_NC 268
  1416. #define R_AARCH64_MOVW_UABS_G3 269
  1417. //
  1418. // Group relocations to create a 16, 32, 48, or 64 bit signed ata or offset
  1419. // value inline.
  1420. // S + A
  1421. //
  1422. #define R_AARCH64_MOVW_SABS_G0 270
  1423. #define R_AARCH64_MOVW_SABS_G1 271
  1424. #define R_AARCH64_MOVW_SABS_G2 272
  1425. //
  1426. // Relocations to generate 19, 21, and 33 bit PC-relative addresses
  1427. // S + A - P
  1428. //
  1429. #define R_AARCH64_LD_PREL_LO19 273
  1430. #define R_AARCH64_ADR_PREL_LO21 274
  1431. //
  1432. // Page(S + A) - Page(P)
  1433. //
  1434. #define R_AARCH64_ADR_PREL_PG_HI21 275
  1435. #define R_AARCH64_ADR_PREL_PG_HI21_NC 276
  1436. //
  1437. // S + A
  1438. //
  1439. #define R_AARCH64_ADD_ABS_LO12_NC 277
  1440. #define R_AARCH64_LDST8_ABS_LO12_NC 278
  1441. #define R_AARCH64_LDST16_ABS_LO12_NC 284
  1442. #define R_AARCH64_LDST32_ABS_LO12_NC 285
  1443. #define R_AARCH64_LDST64_ABS_LO12_NC 286
  1444. #define R_AARCH64_LDST128_ABS_LO12_NC 299
  1445. //
  1446. // Relocations for control-flow instructions. All offsets are a multiple of 4.
  1447. // S + A - P
  1448. #define R_AARCH64_TSTBR14 279
  1449. #define R_AARCH64_CONDBR19 280
  1450. #define R_AARCH64_JUMP26 282
  1451. #define R_AARCH64_CALL26 283
  1452. //
  1453. // Group relocations to create a 16, 32, 48, or 64-bit PC-relative offset
  1454. // inline
  1455. // S + A - P
  1456. //
  1457. #define R_AARCH64_MOVW_PREL_G0 287
  1458. #define R_AARCH64_MOVW_PREL_G0_NC 288
  1459. #define R_AARCH64_MOVW_PREL_G1 289
  1460. #define R_AARCH64_MOVW_PREL_G1_NC 290
  1461. #define R_AARCH64_MOVW_PREL_G2 291
  1462. #define R_AARCH64_MOVW_PREL_G2_NC 292
  1463. #define R_AARCH64_MOVW_PREL_G3 293
  1464. //
  1465. // Group relocations to create a 16, 32, 48, or 64 bit GOT-relative offset
  1466. // inline.
  1467. // G(S) - GOT
  1468. //
  1469. #define R_AARCH64_MOVW_GOTOFF_G0 300
  1470. #define R_AARCH64_MOVW_GOTOFF_G0_NC 301
  1471. #define R_AARCH64_MOVW_GOTOFF_G1 302
  1472. #define R_AARCH64_MOVW_GOTOFF_G1_NC 303
  1473. #define R_AARCH64_MOVW_GOTOFF_G2 304
  1474. #define R_AARCH64_MOVW_GOTOFF_G2_NC 305
  1475. #define R_AARCH64_MOVW_GOTOFF_G3 306
  1476. //
  1477. // GOT-relative data relocations
  1478. // S + A - GOT
  1479. //
  1480. #define R_AARCH64_GOTREL64 307
  1481. #define R_AARCH64_GOTREL32 308
  1482. //
  1483. // GOT-relative instruction relocations
  1484. //
  1485. //
  1486. // G(S) - P
  1487. //
  1488. #define R_AARCH64_GOT_LD_PREL19 309
  1489. //
  1490. // G(S) - GOT
  1491. //
  1492. #define R_AARCH64_LD64_GOTOFF_LO15 310
  1493. //
  1494. // Page(G(S)) - Page(P)
  1495. //
  1496. #define R_AARCH64_ADR_GOT_PAGE 311
  1497. //
  1498. // G(S)
  1499. //
  1500. #define R_AARCH64_LD64_GOT_LO12_NC 312
  1501. //
  1502. // G(S) - Page(GOT)
  1503. //
  1504. #define R_AARCH64_LD64_GOTPAGE_LO15 313
  1505. //
  1506. // Relocations for thread-local storage. General dynamic TLS relocations
  1507. //
  1508. //
  1509. // G(TLSIDX(S + A)) - P
  1510. //
  1511. #define R_AARCH64_TLSGD_ADR_PREL21 512
  1512. //
  1513. // Page(G(TLSIDX(S + A))) - Page(P)
  1514. //
  1515. #define R_AARCH64_TLSGD_ADR_PAGE21 513
  1516. //
  1517. // G(TLSIDX(S + A)
  1518. //
  1519. #define R_AARCH64_TLSGD_ADD_LO12_NC 514
  1520. //
  1521. // G(TLSIDX(S + A)) - GOT
  1522. //
  1523. #define R_AARCH64_TLSGD_MOVW_G1 515
  1524. #define R_AARCH64_TLSGD_MOVW_G0_NC 516
  1525. //
  1526. // Local Dynamic TLS relocations
  1527. //
  1528. //
  1529. // G(LDM(S))) - P
  1530. //
  1531. #define R_AARCH64_TLSLD_ADR_PREL21 517
  1532. //
  1533. // Page(G(LDM(S))) - Page(P)
  1534. //
  1535. #define R_AARCH64_TLSLD_ADR_PAGE21 518
  1536. //
  1537. // G(LDM(S))
  1538. //
  1539. #define R_AARCH64_TLSLD_ADD_LO12_NC 519
  1540. //
  1541. // G(LDM(S)) - GOT
  1542. //
  1543. #define R_AARCH64_TLSLD_MOVW_G1 520
  1544. #define R_AARCH64_TLSLD_MOVW_G0_NC 521
  1545. //
  1546. // G(LDM(S)) - P
  1547. //
  1548. #define R_AARCH64_TLSLD_LD_PREL19 522
  1549. //
  1550. // DTPREL(S + A)
  1551. //
  1552. #define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523
  1553. #define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524
  1554. #define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525
  1555. #define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526
  1556. #define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 527
  1557. #define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528
  1558. #define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529
  1559. #define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530
  1560. #define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531
  1561. #define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532
  1562. #define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533
  1563. #define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534
  1564. #define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535
  1565. #define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536
  1566. #define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537
  1567. #define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538
  1568. //
  1569. // Initial Exec TLS relocations
  1570. // G(TPREL(S + A)) - GOT
  1571. //
  1572. #define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539
  1573. #define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540
  1574. //
  1575. // Page(G(TPREL(S + A))) - Page(P)
  1576. //
  1577. #define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541
  1578. //
  1579. // G(TPREL(S + A))
  1580. //
  1581. #define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542
  1582. //
  1583. // G(TPREL(S + A)) - P
  1584. //
  1585. #define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543
  1586. //
  1587. // Local Exec TLS relocations
  1588. // TPREL(S + A)
  1589. //
  1590. #define R_AARCH64_TLSLE_MOVW_TPREL_G2 544
  1591. #define R_AARCH64_TLSLE_MOVW_TPREL_G1 545
  1592. #define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546
  1593. #define R_AARCH64_TLSLE_MOVW_TPREL_G0 547
  1594. #define R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 548
  1595. #define R_AARCH64_TLSLE_ADD_TPREL_HI12 549
  1596. #define R_AARCH64_TLSLE_ADD_TPREL_LO12 550
  1597. #define R_AARCH64_TLSLE_ADD_TPREL_LO12_NC 551
  1598. #define R_AARCH64_TLSLE_LDST8_TPREL_LO12 552
  1599. #define R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC 553
  1600. #define R_AARCH64_TLSLE_LDST16_TPREL_LO12 554
  1601. #define R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC 555
  1602. #define R_AARCH64_TLSLE_LDST32_TPREL_LO12 556
  1603. #define R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC 557
  1604. #define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558
  1605. #define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559
  1606. //
  1607. // Dynamic relocations
  1608. //
  1609. #define R_AARCH64_COPY 1024
  1610. //
  1611. // S + A
  1612. //
  1613. #define R_AARCH64_GLOB_DAT 1025
  1614. #define R_AARCH64_JUMP_SLOT 1026
  1615. //
  1616. // Delta(S) + A, Delta(P) + A
  1617. //
  1618. #define R_AARCH64_RELATIVE 1027
  1619. //
  1620. // DTPREL(S + A)
  1621. //
  1622. #define R_AARCH64_TLS_DTPREL64 1028
  1623. //
  1624. // LDM(S)
  1625. //
  1626. #define R_AARCH64_TLS_DTPMOD64 1029
  1627. //
  1628. // TPREL(S + A)
  1629. //
  1630. #define R_AARCH64_TLS_TPREL64 1030
  1631. //
  1632. // DTPREL(S + A)
  1633. //
  1634. #define R_AARCH64_TLS_DTPREL32 1031
  1635. //
  1636. // LDM(S)
  1637. //
  1638. #define R_AARCH64_TLS_DTPMOD32 1032
  1639. //
  1640. // DTPREL(S + A)
  1641. //
  1642. #define R_AARCH64_TLS_TPREL32 1033
  1643. //
  1644. // Alpha relocations
  1645. //
  1646. //
  1647. // No relocation
  1648. //
  1649. #define R_ALPHA_NONE 0
  1650. //
  1651. // Direct 32-bit
  1652. //
  1653. #define R_ALPHA_REFLONG 1
  1654. //
  1655. // Direct 64-bit
  1656. //
  1657. #define R_ALPHA_REFQUAD 2
  1658. //
  1659. // GP relative 32-bit
  1660. //
  1661. #define R_ALPHA_GPREL32 3
  1662. //
  1663. // GP relative 16-bit with optimization
  1664. //
  1665. #define R_ALPHA_LITERAL 4
  1666. //
  1667. // Optimization hint for literal
  1668. //
  1669. #define R_ALPHA_LITUSE 5
  1670. //
  1671. // Add displacement to GP
  1672. //
  1673. #define R_ALPHA_GPDISP 6
  1674. //
  1675. // PC + 4 relative 23-bit shifted
  1676. //
  1677. #define R_ALPHA_BRADDR 7
  1678. //
  1679. // PC + 4 relative 16-bit shifted
  1680. //
  1681. #define R_ALPHA_HINT 8
  1682. //
  1683. // PC relateive 16 bit
  1684. //
  1685. #define R_ALPHA_SREL16 9
  1686. //
  1687. // PC relative 32-bit
  1688. //
  1689. #define R_ALPHA_SREL32 10
  1690. //
  1691. // PC relative 64-bit
  1692. //
  1693. #define R_ALPHA_SREL64 11
  1694. //
  1695. // OP stack push
  1696. //
  1697. #define R_ALPHA_OP_PUSH 12
  1698. //
  1699. // OP stack pop and store
  1700. //
  1701. #define R_ALPHA_OP_STORE 13
  1702. //
  1703. // OP stack add
  1704. //
  1705. #define R_ALPHA_OP_PSUB 14
  1706. //
  1707. // OP stack right shift
  1708. //
  1709. #define R_ALPHA_OP_PRSHIFT 15
  1710. #define R_ALPHA_GPVALUE 16
  1711. #define R_ALPHA_GPRELHIGH 17
  1712. #define R_ALPHA_GPRELLOW 18
  1713. #define R_ALPHA_IMMED_GP_16 19
  1714. #define R_ALPHA_IMMED_GP_HI32 20
  1715. #define R_ALPHA_IMMED_SCN_HI32 21
  1716. #define R_ALPHA_IMMED_BR_HI32 22
  1717. #define R_ALPHA_IMMED_LO32 23
  1718. //
  1719. // Copy symbol at runtime
  1720. //
  1721. #define R_ALPHA_COPY 24
  1722. //
  1723. // Create GOT entry
  1724. //
  1725. #define R_ALPHA_GLOB_DAT 25
  1726. //
  1727. // Create PLT entry
  1728. //
  1729. #define R_ALPHA_JMP_SLOT 26
  1730. //
  1731. // Adjust by program base
  1732. //
  1733. #define R_ALPHA_RELATIVE 27
  1734. //
  1735. // ARM relocations
  1736. //
  1737. #define R_ARM_NONE 0
  1738. #define R_ARM_PC24 1
  1739. #define R_ARM_ABS32 2
  1740. #define R_ARM_REL32 3
  1741. #define R_ARM_PC13 4
  1742. #define R_ARM_ABS16 5
  1743. #define R_ARM_ABS12 6
  1744. #define R_ARM_THM_ABS5 7
  1745. #define R_ARM_ABS8 8
  1746. #define R_ARM_SBREL32 9
  1747. #define R_ARM_THM_PC22 10
  1748. #define R_ARM_THM_PC8 11
  1749. #define R_ARM_AMP_VCALL9 12
  1750. #define R_ARM_SWI24 13
  1751. #define R_ARM_THM_SWI8 14
  1752. #define R_ARM_XPC25 15
  1753. #define R_ARM_THM_XPC22 16
  1754. #define R_ARM_BASE_PREL 25
  1755. #define R_ARM_GOT_BREL 26
  1756. //
  1757. // Copy data from shared object
  1758. //
  1759. #define R_ARM_COPY 20
  1760. //
  1761. // Set GOT entry to data address
  1762. //
  1763. #define R_ARM_GLOB_DAT 21
  1764. //
  1765. // Set GOT entry to code address
  1766. //
  1767. #define R_ARM_JUMP_SLOT 22
  1768. //
  1769. // Add load address of shared object
  1770. //
  1771. #define R_ARM_RELATIVE 23
  1772. //
  1773. // Add GOT-relative symbol address
  1774. //
  1775. #define R_ARM_GOTOFF 24
  1776. //
  1777. // Add PC-relative GOT table address
  1778. //
  1779. #define R_ARM_GOTPC 25
  1780. //
  1781. // Add PC-relative GOT offset
  1782. //
  1783. #define R_ARM_GOT32 26
  1784. //
  1785. // Add PC-relative PLT offset
  1786. //
  1787. #define R_ARM_PLT32 27
  1788. #define R_ARM_CALL 28
  1789. #define R_ARM_JMP24 29
  1790. #define R_ARM_THM_MOVW_ABS_NC 47
  1791. #define R_ARM_THM_MOVT_ABS 48
  1792. //
  1793. // This block of PC-relative relocations was added to work around GCC putting
  1794. // object relocations in static executables.
  1795. //
  1796. #define R_ARM_THM_JUMP24 30
  1797. #define R_ARM_PREL31 42
  1798. #define R_ARM_MOVW_PREL_NC 45
  1799. #define R_ARM_MOVT_PREL 46
  1800. #define R_ARM_THM_MOVW_PREL_NC 49
  1801. #define R_ARM_THM_MOVT_PREL 50
  1802. #define R_ARM_THM_JMP6 52
  1803. #define R_ARM_THM_ALU_PREL_11_0 53
  1804. #define R_ARM_THM_PC12 54
  1805. #define R_ARM_REL32_NOI 56
  1806. #define R_ARM_ALU_PC_G0_NC 57
  1807. #define R_ARM_ALU_PC_G0 58
  1808. #define R_ARM_ALU_PC_G1_NC 59
  1809. #define R_ARM_ALU_PC_G1 60
  1810. #define R_ARM_ALU_PC_G2 61
  1811. #define R_ARM_LDR_PC_G1 62
  1812. #define R_ARM_LDR_PC_G2 63
  1813. #define R_ARM_LDRS_PC_G0 64
  1814. #define R_ARM_LDRS_PC_G1 65
  1815. #define R_ARM_LDRS_PC_G2 66
  1816. #define R_ARM_LDC_PC_G0 67
  1817. #define R_ARM_LDC_PC_G1 68
  1818. #define R_ARM_LDC_PC_G2 69
  1819. #define R_ARM_GOT_PREL 96
  1820. #define R_ARM_THM_JUMP11 102
  1821. #define R_ARM_THM_JUMP8 103
  1822. #define R_ARM_TLS_GD32 104
  1823. #define R_ARM_TLS_LDM32 105
  1824. #define R_ARM_TLS_IE32 107
  1825. #define R_ARM_THM_JUMP19 51
  1826. #define R_ARM_GNU_VTENTRY 100
  1827. #define R_ARM_GNU_VTINHERIT 101
  1828. #define R_ARM_RSBREL32 250
  1829. #define R_ARM_THM_RPC22 251
  1830. #define R_ARM_RREL32 252
  1831. #define R_ARM_RABS32 253
  1832. #define R_ARM_RPC24 254
  1833. #define R_ARM_RBASE 255
  1834. //
  1835. // IA-64 relocations
  1836. //
  1837. #define R_IA_64_NONE 0
  1838. //
  1839. // Immediate14 S + A
  1840. //
  1841. #define R_IA_64_IMM14 0x21
  1842. //
  1843. // Immediate22 S + A
  1844. //
  1845. #define R_IA_64_IMM22 0x22
  1846. //
  1847. // Immediate64 S + A
  1848. //
  1849. #define R_IA_64_IMM64 0x23
  1850. //
  1851. // Word32 MSB S + A
  1852. //
  1853. #define R_IA_64_DIR32MSB 0x24
  1854. //
  1855. // Word32 LSB S + A
  1856. //
  1857. #define R_IA_64_DIR32LSB 0x25
  1858. //
  1859. // Word64 MSB S + A
  1860. //
  1861. #define R_IA_64_DIR64MSB 0x26
  1862. //
  1863. // Word64 LSB S + A
  1864. //
  1865. #define R_IA_64_DIR64LSB 0x27
  1866. //
  1867. // Immediate22 @gprel(S + A)
  1868. //
  1869. #define R_IA_64_GPREL22 0x2a
  1870. //
  1871. // Immediate64 @gprel(S + A)
  1872. //
  1873. #define R_IA_64_GPREL64I 0x2b
  1874. //
  1875. // Word32 MSB @gprel(S + A)
  1876. //
  1877. #define R_IA_64_GPREL32MSB 0x2c
  1878. //
  1879. // Word32 LSB @gprel(S + A)
  1880. //
  1881. #define R_IA_64_GPREL32LSB 0x2d
  1882. //
  1883. // Word64 MSB @gprel(S + A)
  1884. //
  1885. #define R_IA_64_GPREL64MSB 0x2e
  1886. //
  1887. // Word64 LSB @gprel(S + A)
  1888. //
  1889. #define R_IA_64_GPREL64LSB 0x2f
  1890. //
  1891. // Immediate22 @ltoff(S + A)
  1892. //
  1893. #define R_IA_64_LTOFF22 0x32
  1894. //
  1895. // Immediate64 @ltoff (S + A)
  1896. //
  1897. #define R_IA_64_LTOFF64I 0x33
  1898. //
  1899. // Immediate22 @pltoff(S + A)
  1900. //
  1901. #define R_IA_64_PLTOFF22 0x3a
  1902. //
  1903. // Immediate64 @pltoff(S + A)
  1904. //
  1905. #define R_IA_64_PLTOFF64I 0x3b
  1906. //
  1907. // Word64 MSB @pltoff(S + A)
  1908. //
  1909. #define R_IA_64_PLTOFF64MSB 0x3e
  1910. //
  1911. // Word64 LSB @pltoff(S + A)
  1912. //
  1913. #define R_IA_64_PLTOFF64LSB 0x3f
  1914. //
  1915. // Immediate64 @fptr(S + A)
  1916. //
  1917. #define R_IA_64_FPTR64I 0x43
  1918. //
  1919. // Word32 MSB @fptr(S + A)
  1920. //
  1921. #define R_IA_64_FPTR32MSB 0x44
  1922. //
  1923. // Word32 LSB @fptr(S + A)
  1924. //
  1925. #define R_IA_64_FPTR32LSB 0x45
  1926. //
  1927. // Word64 MSB @fptr(S + A)
  1928. //
  1929. #define R_IA_64_FPTR64MSB 0x46
  1930. //
  1931. // Word64 LSB @fptr(S + A)
  1932. //
  1933. #define R_IA_64_FPTR64LSB 0x47
  1934. //
  1935. // Immediate60 form1 S + A - P
  1936. //
  1937. #define R_IA_64_PCREL60B 0x48
  1938. //
  1939. // Immediate21 forms 1, 2, and 3 S + A - P
  1940. //
  1941. #define R_IA_64_PCREL21B 0x49
  1942. #define R_IA_64_PCREL21M 0x4a
  1943. #define R_IA_64_PCREL21F 0x4b
  1944. //
  1945. // Word32/64 MSB and LSB: S + A - P
  1946. //
  1947. #define R_IA_64_PCREL32MSB 0x4c
  1948. #define R_IA_64_PCREL32LSB 0x4d
  1949. #define R_IA_64_PCREL64MSB 0x4e
  1950. #define R_IA_64_PCREL64LSB 0x4f
  1951. //
  1952. // Immediate22/64 @ltoff(@fptr(S + A))
  1953. //
  1954. #define R_IA_64_LTOFF_FPTR22 0x52
  1955. #define R_IA_64_LTOFF_FPTR64I 0x53
  1956. //
  1957. // Word32/64 MSB and LSB: @ltoff(@fptr(S + A))
  1958. //
  1959. #define R_IA_64_LTOFF_FPTR32MSB 0x54
  1960. #define R_IA_64_LTOFF_FPTR32LSB 0x55
  1961. #define R_IA_64_LTOFF_FPTR64MSB 0x56
  1962. #define R_IA_64_LTOFF_FPTR64LSB 0x57
  1963. //
  1964. // Word32/64 MSB/LSB: @segrel(S + A)
  1965. //
  1966. #define R_IA_64_SEGREL32MSB 0x5c
  1967. #define R_IA_64_SEGREL32LSB 0x5d
  1968. #define R_IA_64_SEGREL64MSB 0x5e
  1969. #define R_IA_64_SEGREL64LSB 0x5f
  1970. //
  1971. // Word32/64 MSB/LSB @secrel(S + A)
  1972. //
  1973. #define R_IA_64_SECREL32MSB 0x64
  1974. #define R_IA_64_SECREL32LSB 0x65
  1975. #define R_IA_64_SECREL64MSB 0x66
  1976. #define R_IA_64_SECREL64LSB 0x67
  1977. //
  1978. // Word32/64 MSB/LSB: BD + A
  1979. //
  1980. #define R_IA_64_REL32MSB 0x6c
  1981. #define R_IA_64_REL32LSB 0x6d
  1982. #define R_IA_64_REL64MSB 0x6e
  1983. #define R_IA_64_REL64LSB 0x6f
  1984. //
  1985. // Word32/64 MSB/LSB: S + A
  1986. //
  1987. #define R_IA_64_LTV32MSB 0x74
  1988. #define R_IA_64_LTV32LSB 0x75
  1989. #define R_IA_64_LTV64MSB 0x76
  1990. #define R_IA_64_LTV64LSB 0x77
  1991. //
  1992. // Immediate21 form1 S + A - P
  1993. //
  1994. #define R_IA_64_PCREL21BI 0x79
  1995. //
  1996. // Immediate22/64: S + A - P
  1997. //
  1998. #define R_IA_64_PCREL22 0x7a
  1999. #define R_IA_64_PCREL64I 0x7b
  2000. //
  2001. // Function descriptor MSB/LSB special
  2002. //
  2003. #define R_IA_64_IPLTMSB 0x80
  2004. #define R_IA_64_IPLTLSB 0x81
  2005. //
  2006. // Immediate64: A - S
  2007. //
  2008. #define R_IA_64_SUB 0x85
  2009. //
  2010. // Immediate22 special
  2011. //
  2012. #define R_IA_64_LTOFF22X 0x86
  2013. #define R_IA_64_LDXMOV 0x87
  2014. //
  2015. // Immediate14/22/64 @tprel(S + A)
  2016. //
  2017. #define R_IA_64_TPREL14 0x91
  2018. #define R_IA_64_TPREL22 0x92
  2019. #define R_IA_64_TPREL64I 0x93
  2020. //
  2021. // Word64 MSB/LSB @tprel(S + A)
  2022. //
  2023. #define R_IA_64_TPREL64MSB 0x96
  2024. #define R_IA_64_TPREL64LSB 0x97
  2025. //
  2026. // Immediate22 @ltoff(@tprel(S + A))
  2027. //
  2028. #define R_IA_64_LTOFF_TPREL22 0x9a
  2029. //
  2030. // Word64 MSB/LSB @dtpmod(S + A)
  2031. //
  2032. #define R_IA_64_DTPMOD64MSB 0xa6
  2033. #define R_IA_64_DTPMOD64LSB 0xa7
  2034. //
  2035. // Immediate22 @ltoff(@dtpmod(S + A))
  2036. //
  2037. #define R_IA_64_LTOFF_DTPMOD22 0xaa
  2038. //
  2039. // Immediate14/22/64 @dtprel(S + A)
  2040. //
  2041. #define R_IA_64_DTPREL14 0xb1
  2042. #define R_IA_64_DTPREL22 0xb2
  2043. #define R_IA_64_DTPREL64I 0xb3
  2044. //
  2045. // Word32/64 MSB/LSB @dtprel(S + A)
  2046. //
  2047. #define R_IA_64_DTPREL32MSB 0xb4
  2048. #define R_IA_64_DTPREL32LSB 0xb5
  2049. #define R_IA_64_DTPREL64MSB 0xb6
  2050. #define R_IA_64_DTPREL64LSB 0xb7
  2051. //
  2052. // Immediate22 @ltof(@dtprel(S + A))
  2053. //
  2054. #define R_IA_64_LTOFF_DTPREL22 0xba
  2055. //
  2056. // PowerPC relocations
  2057. //
  2058. #define R_PPC_NONE 0
  2059. #define R_PPC_ADDR32 1
  2060. #define R_PPC_ADDR24 2
  2061. #define R_PPC_ADDR16 3
  2062. #define R_PPC_ADDR16_LO 4
  2063. #define R_PPC_ADDR16_HI 5
  2064. #define R_PPC_ADDR16_HA 6
  2065. #define R_PPC_ADDR14 7
  2066. #define R_PPC_ADDR14_BRTAKEN 8
  2067. #define R_PPC_ADDR14_BRNTAKEN 9
  2068. #define R_PPC_REL24 10
  2069. #define R_PPC_REL14 11
  2070. #define R_PPC_REL14_BRTAKEN 12
  2071. #define R_PPC_REL14_BRNTAKEN 13
  2072. #define R_PPC_GOT16 14
  2073. #define R_PPC_GOT16_LO 15
  2074. #define R_PPC_GOT16_HI 16
  2075. #define R_PPC_GOT16_HA 17
  2076. #define R_PPC_PLTREL24 18
  2077. #define R_PPC_COPY 19
  2078. #define R_PPC_GLOB_DAT 20
  2079. #define R_PPC_JMP_SLOT 21
  2080. #define R_PPC_RELATIVE 22
  2081. #define R_PPC_LOCAL24PC 23
  2082. #define R_PPC_UADDR32 24
  2083. #define R_PPC_UADDR16 25
  2084. #define R_PPC_REL32 26
  2085. #define R_PPC_PLT32 27
  2086. #define R_PPC_PLTREL32 28
  2087. #define R_PPC_PLT16_LO 29
  2088. #define R_PPC_PLT16_HI 30
  2089. #define R_PPC_PLT16_HA 31
  2090. #define R_PPC_SDAREL16 32
  2091. #define R_PPC_SECTOFF 33
  2092. #define R_PPC_SECTOFF_LO 34
  2093. #define R_PPC_SECTOFF_HI 35
  2094. #define R_PPC_SECTOFF_HA 36
  2095. //
  2096. // PowerPC TLS relocations
  2097. //
  2098. #define R_PPC_TLS 67
  2099. #define R_PPC_DTPMOD32 68
  2100. #define R_PPC_TPREL16 69
  2101. #define R_PPC_TPREL16_LO 70
  2102. #define R_PPC_TPREL16_HI 71
  2103. #define R_PPC_TPREL16_HA 72
  2104. #define R_PPC_TPREL32 73
  2105. #define R_PPC_DTPREL16 74
  2106. #define R_PPC_DTPREL16_LO 75
  2107. #define R_PPC_DTPREL16_HI 76
  2108. #define R_PPC_DTPREL16_HA 77
  2109. #define R_PPC_DTPREL32 78
  2110. #define R_PPC_GOT_TLSGD16 79
  2111. #define R_PPC_GOT_TLSGD16_LO 80
  2112. #define R_PPC_GOT_TLSGD16_HI 81
  2113. #define R_PPC_GOT_TLSGD16_HA 82
  2114. #define R_PPC_GOT_TLSLD16 83
  2115. #define R_PPC_GOT_TLSLD16_LO 84
  2116. #define R_PPC_GOT_TLSLD16_HI 85
  2117. #define R_PPC_GOT_TLSLD16_HA 86
  2118. #define R_PPC_GOT_TPREL16 87
  2119. #define R_PPC_GOT_TPREL16_LO 88
  2120. #define R_PPC_GOT_TPREL16_HI 89
  2121. #define R_PPC_GOT_TPREL16_HA 90
  2122. //
  2123. // The remaining PowerPC relocations are from the embedded ELF API, and are not
  2124. // in the SVR4 ELF ABI.
  2125. //
  2126. #define R_PPC_EMB_NADDR32 101
  2127. #define R_PPC_EMB_NADDR16 102
  2128. #define R_PPC_EMB_NADDR16_LO 103
  2129. #define R_PPC_EMB_NADDR16_HI 104
  2130. #define R_PPC_EMB_NADDR16_HA 105
  2131. #define R_PPC_EMB_SDAI16 106
  2132. #define R_PPC_EMB_SDA2I16 107
  2133. #define R_PPC_EMB_SDA2REL 108
  2134. #define R_PPC_EMB_SDA21 109
  2135. #define R_PPC_EMB_MRKREF 110
  2136. #define R_PPC_EMB_RELSEC16 111
  2137. #define R_PPC_EMB_RELST_LO 112
  2138. #define R_PPC_EMB_RELST_HI 113
  2139. #define R_PPC_EMB_RELST_HA 114
  2140. #define R_PPC_EMB_BIT_FLD 115
  2141. #define R_PPC_EMB_RELSDA 116
  2142. #define R_SPARC_NONE 0
  2143. #define R_SPARC_8 1
  2144. #define R_SPARC_16 2
  2145. #define R_SPARC_32 3
  2146. #define R_SPARC_DISP8 4
  2147. #define R_SPARC_DISP16 5
  2148. #define R_SPARC_DISP32 6
  2149. #define R_SPARC_WDISP30 7
  2150. #define R_SPARC_WDISP22 8
  2151. #define R_SPARC_HI22 9
  2152. #define R_SPARC_22 10
  2153. #define R_SPARC_13 11
  2154. #define R_SPARC_LO10 12
  2155. #define R_SPARC_GOT10 13
  2156. #define R_SPARC_GOT13 14
  2157. #define R_SPARC_GOT22 15
  2158. #define R_SPARC_PC10 16
  2159. #define R_SPARC_PC22 17
  2160. #define R_SPARC_WPLT30 18
  2161. #define R_SPARC_COPY 19
  2162. #define R_SPARC_GLOB_DAT 20
  2163. #define R_SPARC_JMP_SLOT 21
  2164. #define R_SPARC_RELATIVE 22
  2165. #define R_SPARC_UA32 23
  2166. #define R_SPARC_PLT32 24
  2167. #define R_SPARC_HIPLT22 25
  2168. #define R_SPARC_LOPLT10 26
  2169. #define R_SPARC_PCPLT32 27
  2170. #define R_SPARC_PCPLT22 28
  2171. #define R_SPARC_PCPLT10 29
  2172. #define R_SPARC_10 30
  2173. #define R_SPARC_11 31
  2174. #define R_SPARC_64 32
  2175. #define R_SPARC_OLO10 33
  2176. #define R_SPARC_HH22 34
  2177. #define R_SPARC_HM10 35
  2178. #define R_SPARC_LM22 36
  2179. #define R_SPARC_PC_HH22 37
  2180. #define R_SPARC_PC_HM10 38
  2181. #define R_SPARC_PC_LM22 39
  2182. #define R_SPARC_WDISP16 40
  2183. #define R_SPARC_WDISP19 41
  2184. #define R_SPARC_GLOB_JMP 42
  2185. #define R_SPARC_7 43
  2186. #define R_SPARC_5 44
  2187. #define R_SPARC_6 45
  2188. #define R_SPARC_DISP64 46
  2189. #define R_SPARC_PLT64 47
  2190. #define R_SPARC_HIX22 48
  2191. #define R_SPARC_LOX10 49
  2192. #define R_SPARC_H44 50
  2193. #define R_SPARC_M44 51
  2194. #define R_SPARC_L44 52
  2195. #define R_SPARC_REGISTER 53
  2196. #define R_SPARC_UA64 54
  2197. #define R_SPARC_UA16 55
  2198. #define R_SPARC_TLS_GD_HI22 56
  2199. #define R_SPARC_TLS_GD_LO10 57
  2200. #define R_SPARC_TLS_GD_ADD 58
  2201. #define R_SPARC_TLS_GD_CALL 59
  2202. #define R_SPARC_TLS_LDM_HI22 60
  2203. #define R_SPARC_TLS_LDM_LO10 61
  2204. #define R_SPARC_TLS_LDM_ADD 62
  2205. #define R_SPARC_TLS_LDM_CALL 63
  2206. #define R_SPARC_TLS_LDO_HIX22 64
  2207. #define R_SPARC_TLS_LDO_LOX10 65
  2208. #define R_SPARC_TLS_LDO_ADD 66
  2209. #define R_SPARC_TLS_IE_HI22 67
  2210. #define R_SPARC_TLS_IE_LO10 68
  2211. #define R_SPARC_TLS_IE_LD 69
  2212. #define R_SPARC_TLS_IE_LDX 70
  2213. #define R_SPARC_TLS_IE_ADD 71
  2214. #define R_SPARC_TLS_LE_HIX22 72
  2215. #define R_SPARC_TLS_LE_LOX10 73
  2216. #define R_SPARC_TLS_DTPMOD32 74
  2217. #define R_SPARC_TLS_DTPMOD64 75
  2218. #define R_SPARC_TLS_DTPOFF32 76
  2219. #define R_SPARC_TLS_DTPOFF64 77
  2220. #define R_SPARC_TLS_TPOFF32 78
  2221. #define R_SPARC_TLS_TPOFF64 79
  2222. //
  2223. // AMD64 relocations
  2224. //
  2225. #define R_X86_64_NONE 0
  2226. //
  2227. // Add 64-bit symbol value
  2228. //
  2229. #define R_X86_64_64 1
  2230. //
  2231. // PC-relative 32-bit signed symbol value
  2232. //
  2233. #define R_X86_64_PC32 2
  2234. //
  2235. // PC-relative 32-bit GOT offset
  2236. //
  2237. #define R_X86_64_GOT32 3
  2238. //
  2239. // PC-relative 32-bit PLT offset
  2240. //
  2241. #define R_X86_64_PLT32 4
  2242. //
  2243. // Copy data from the shared object
  2244. //
  2245. #define R_X86_64_COPY 5
  2246. //
  2247. // Set GOT entry to data address
  2248. //
  2249. #define R_X86_64_GLOB_DAT 6
  2250. //
  2251. // Set GOT entry to code address
  2252. //
  2253. #define R_X86_64_JMP_SLOT 7
  2254. //
  2255. // Add the load address of the shared object
  2256. //
  2257. #define R_X86_64_RELATIVE 8
  2258. //
  2259. // Add 32-bit signed PC-relative offset to GOT
  2260. //
  2261. #define R_X86_64_GOTPCREL 9
  2262. //
  2263. // Add 32-bit zero extended symbol value
  2264. //
  2265. #define R_X86_64_32 10
  2266. //
  2267. // Add 32-bit sign-extended symbol value
  2268. //
  2269. #define R_X86_64_32S 11
  2270. //
  2271. // Add 16-bit zero extended symbol value
  2272. //
  2273. #define R_X86_64_16 12
  2274. //
  2275. // Add 16-bit sign-extended PC-relative symbol value
  2276. //
  2277. #define R_X86_64_PC16 13
  2278. //
  2279. // Add 8-bit zero extended symbol value
  2280. //
  2281. #define R_X86_64_8 14
  2282. //
  2283. // Add 8-bit sign-extended PC-relative symbol value
  2284. //
  2285. #define R_X86_64_PC8 15
  2286. //
  2287. // ID of the module containing the symbol
  2288. //
  2289. #define R_X86_64_DTPMOD64 16
  2290. //
  2291. // Offset in the TLS block
  2292. //
  2293. #define R_X86_64_DTPOFF64 17
  2294. //
  2295. // Offset in the static TLS block
  2296. //
  2297. #define R_X86_64_TPOFF64 18
  2298. //
  2299. // PC-relative offset to GD GOT entry
  2300. //
  2301. #define R_X86_64_TLSGD 19
  2302. //
  2303. // PC-relative offset to LD GOT entry
  2304. //
  2305. #define R_X86_64_TLSLD 20
  2306. //
  2307. // Offset in TLS block
  2308. //
  2309. #define R_X86_64_DTPOFF32 21
  2310. //
  2311. // PC-relative offset to IE GOT entry
  2312. //
  2313. #define R_X86_64_GOTTPOFF 22
  2314. //
  2315. // Offset in static TLS block
  2316. //
  2317. #define R_X86_64_TPOFF32 23
  2318. //
  2319. // ------------------------------------------------------ Data Type Definitions
  2320. //
  2321. //
  2322. // Common ELF definitions
  2323. //
  2324. /*++
  2325. Structure Description:
  2326. This structure defines an ELF note header. The ".note" section contains an
  2327. array of notes. Each not begins with this header, aligned to a word
  2328. boundary. After the note header is n_namesz bytes of name, padded to the
  2329. next word boundary. Then n_descsz bytes of descriptor, again padded to a
  2330. word boundary. The values of n_namesz and n_descsz to not include the
  2331. padding.
  2332. Members:
  2333. n_namesz - Stores the length of the name.
  2334. n_descsz - Stores the length of the descriptor.
  2335. n_type - Stores the note type.
  2336. --*/
  2337. typedef struct {
  2338. UINT32 n_namesz;
  2339. UINT32 n_descsz;
  2340. UINT32 n_type;
  2341. } Elf_Note;
  2342. //
  2343. // 32-bit ELF definitions
  2344. //
  2345. typedef UINT32 Elf32_Addr;
  2346. typedef UINT16 Elf32_Half;
  2347. typedef UINT32 Elf32_Off;
  2348. typedef INT32 Elf32_Sword;
  2349. typedef UINT32 Elf32_Word;
  2350. typedef UINT64 Elf32_Lword;
  2351. typedef Elf32_Word Elf32_Hashelt;
  2352. //
  2353. // Non-standard class-dependent data type used for abstraction
  2354. //
  2355. typedef Elf32_Word Elf32_Size;
  2356. typedef Elf32_Sword Elf32_Ssize;
  2357. /*++
  2358. Structure Description:
  2359. This structure defines the ELF32 file header.
  2360. Members:
  2361. e_ident - Stores the file identification.
  2362. e_type - Stores the file type.
  2363. e_machine - Stores the machine architecture.
  2364. e_version - Stores the ELF format version.
  2365. e_entry - Stores the entry point.
  2366. e_phoff - Stores the program header file offset.
  2367. e_shoff - Stores the section header file offset.
  2368. e_flags - Stores architecture-specific flags.
  2369. e_ehsize - Stores the size of the ELF header in bytes.
  2370. e_phentsize - Stores the size of the program header entry.
  2371. e_phnum - Stores the size of the program header entries.
  2372. e_shentsize - Stores the size of a section header entry.
  2373. e_shnum - Stores the count of section header entries.
  2374. e_shstrndx - Stores the section name strings section.
  2375. --*/
  2376. typedef struct {
  2377. unsigned char e_ident[EI_NIDENT];
  2378. Elf32_Half e_type;
  2379. Elf32_Half e_machine;
  2380. Elf32_Word e_version;
  2381. Elf32_Addr e_entry;
  2382. Elf32_Off e_phoff;
  2383. Elf32_Off e_shoff;
  2384. Elf32_Word e_flags;
  2385. Elf32_Half e_ehsize;
  2386. Elf32_Half e_phentsize;
  2387. Elf32_Half e_phnum;
  2388. Elf32_Half e_shentsize;
  2389. Elf32_Half e_shnum;
  2390. Elf32_Half e_shstrndx;
  2391. } Elf32_Ehdr;
  2392. /*++
  2393. Structure Description:
  2394. This structure defines the ELF32 section header.
  2395. Members:
  2396. sh_name - Stores the index into the section header string table where the
  2397. section name string can bd found.
  2398. sh_type - Stores the section type.
  2399. sh_flags - Stores the section flags.
  2400. sh_addr - Stores the address in the memory image.
  2401. sh_offset - Stores the file offset of the section.
  2402. sh_size - Stores the size of the section in bytes.
  2403. sh_link - Stores the index of a related section.
  2404. sh_info - Stores a value that depends on the section type.
  2405. sh_addralign - Stores the alignment in bytes.
  2406. sh_entsize - Stores the size of each entry in the section.
  2407. --*/
  2408. typedef struct {
  2409. Elf32_Word sh_name;
  2410. Elf32_Word sh_type;
  2411. Elf32_Word sh_flags;
  2412. Elf32_Addr sh_addr;
  2413. Elf32_Off sh_offset;
  2414. Elf32_Word sh_size;
  2415. Elf32_Word sh_link;
  2416. Elf32_Word sh_info;
  2417. Elf32_Word sh_addralign;
  2418. Elf32_Word sh_entsize;
  2419. } Elf32_Shdr;
  2420. /*++
  2421. Structure Description:
  2422. This structure defines the ELF32 program header.
  2423. Members:
  2424. p_type - Stores the program header type.
  2425. p_offset - Stores the file offset of the contents.
  2426. p_vaddr - Stores the virtual address in the memory image.
  2427. p_paddr - Stores the physical address (not used).
  2428. p_filesz - Stores the size of the contents within the file.
  2429. p_memsz - Stores the size of the contents in memory.
  2430. p_flags - Stores access permission flags.
  2431. p_align - Stores the alignment in memory and in the file.
  2432. --*/
  2433. typedef struct {
  2434. Elf32_Word p_type;
  2435. Elf32_Off p_offset;
  2436. Elf32_Addr p_vaddr;
  2437. Elf32_Addr p_paddr;
  2438. Elf32_Word p_filesz;
  2439. Elf32_Word p_memsz;
  2440. Elf32_Word p_flags;
  2441. Elf32_Word p_align;
  2442. } Elf32_Phdr;
  2443. /*++
  2444. Structure Description:
  2445. This structure defines the ELF32 dynamic section.
  2446. Members:
  2447. d_tag - Stores the entry type.
  2448. d_un - Stores a union of the two different forms of the value.
  2449. d_val - Stores the integer representation of the value.
  2450. d_ptr - Stores the pointer representation of the value.
  2451. --*/
  2452. typedef struct {
  2453. Elf32_Sword d_tag;
  2454. union {
  2455. Elf32_Word d_val;
  2456. Elf32_Addr d_ptr;
  2457. } d_un;
  2458. } Elf32_Dyn;
  2459. /*++
  2460. Structure Description:
  2461. This structure defines the ELF32 relocation entry that does not require
  2462. an addend.
  2463. Members:
  2464. r_offset - Stores the location to be relocated.
  2465. r_info - Stores the relocation type and symbol index.
  2466. --*/
  2467. typedef struct {
  2468. Elf32_Addr r_offset;
  2469. Elf32_Word r_info;
  2470. } Elf32_Rel;
  2471. /*++
  2472. Structure Description:
  2473. This structure defines the ELF32 relocation entry that needs an addend
  2474. field.
  2475. Members:
  2476. r_offset - Stores the location to be relocated.
  2477. r_info - Stores the relocation type and symbol index.
  2478. r_addend - Stores the addend to throw in there.
  2479. --*/
  2480. typedef struct {
  2481. Elf32_Addr r_offset;
  2482. Elf32_Word r_info;
  2483. Elf32_Sword r_addend;
  2484. } Elf32_Rela;
  2485. typedef Elf_Note Elf32_Nhdr;
  2486. /*++
  2487. Structure Description:
  2488. This structure defines the ELF32 move entry.
  2489. Members:
  2490. m_value - Stores the symbol value.
  2491. m_info - Stores the size + index.
  2492. m_poffset - Stores the symbol offset.
  2493. m_repeat - Stores the repeat count.
  2494. m_stride - Stores the stride information.
  2495. --*/
  2496. typedef struct {
  2497. Elf32_Lword m_value;
  2498. Elf32_Word m_info;
  2499. Elf32_Word m_poffset;
  2500. Elf32_Half m_repeat;
  2501. Elf32_Half m_stride;
  2502. } Elf32_Move;
  2503. /*++
  2504. Structure Description:
  2505. This structure defines the ELF32 hardware/software capabilities array.
  2506. Members:
  2507. c_tag - Stores the tag which determines the interpretation of the value.
  2508. c_un - Stores a union of the two different forms of the value.
  2509. c_val - Stores the integer representation of the value.
  2510. c_ptr - Stores the pointer representation of the value.
  2511. --*/
  2512. typedef struct {
  2513. Elf32_Word c_tag;
  2514. union {
  2515. Elf32_Word c_val;
  2516. Elf32_Addr c_ptr;
  2517. } c_un;
  2518. } Elf32_Cap;
  2519. /*++
  2520. Structure Description:
  2521. This structure defines an ELF32 symbol table entry.
  2522. Members:
  2523. st_name - Stores the string table index of the name.
  2524. st_value - Stores the value of the symbol.
  2525. st_size - Stores the size of the associated objct.
  2526. st_info - Stores the type and binding information.
  2527. st_other - Stores a reserved value (not used).
  2528. st_shndx - Stores the section index of the symbol.
  2529. --*/
  2530. typedef struct {
  2531. Elf32_Word st_name;
  2532. Elf32_Addr st_value;
  2533. Elf32_Word st_size;
  2534. unsigned char st_info;
  2535. unsigned char st_other;
  2536. Elf32_Half st_shndx;
  2537. } Elf32_Sym;
  2538. //
  2539. // Structures used by Sun & GNU symbol versioning
  2540. //
  2541. typedef struct {
  2542. Elf32_Half vd_version;
  2543. Elf32_Half vd_flags;
  2544. Elf32_Half vd_ndx;
  2545. Elf32_Half vd_cnt;
  2546. Elf32_Word vd_hash;
  2547. Elf32_Word vd_aux;
  2548. Elf32_Word vd_next;
  2549. } Elf32_Verdef;
  2550. typedef struct {
  2551. Elf32_Word vda_name;
  2552. Elf32_Word vda_next;
  2553. } Elf32_Verdaux;
  2554. typedef struct {
  2555. Elf32_Half vn_version;
  2556. Elf32_Half vn_cnt;
  2557. Elf32_Word vn_file;
  2558. Elf32_Word vn_aux;
  2559. Elf32_Word vn_next;
  2560. } Elf32_Verneed;
  2561. typedef struct {
  2562. Elf32_Word vna_hash;
  2563. Elf32_Half vna_flags;
  2564. Elf32_Half vna_other;
  2565. Elf32_Word vna_name;
  2566. Elf32_Word vna_next;
  2567. } Elf32_Vernaux;
  2568. typedef Elf32_Half Elf32_Versym;
  2569. typedef struct {
  2570. Elf32_Half si_boundto;
  2571. Elf32_Half si_flags;
  2572. } Elf32_Syminfo;
  2573. //
  2574. // 64-bit ELF definitions
  2575. //
  2576. typedef UINT64 Elf64_Addr;
  2577. typedef UINT16 Elf64_Half;
  2578. typedef UINT64 Elf64_Off;
  2579. typedef INT32 Elf64_Sword;
  2580. typedef INT64 Elf64_Sxword;
  2581. typedef UINT32 Elf64_Word;
  2582. typedef UINT64 Elf64_Lword;
  2583. typedef UINT64 Elf64_Xword;
  2584. //
  2585. // Define types of dynamic symbol hash table bucket and chain elements.
  2586. // This is inconsitent among 64-bit architectures, so a machine dependent
  2587. // typedef is required.
  2588. //
  2589. typedef Elf64_Word Elf64_Hashelt;
  2590. //
  2591. // Non-standard class-dependent data types used for abstraction.
  2592. //
  2593. typedef Elf64_Xword Elf64_Size;
  2594. typedef Elf64_Sxword Elf64_Ssize;
  2595. /*++
  2596. Structure Description:
  2597. This structure defines the ELF64 file header.
  2598. Members:
  2599. e_ident - Stores the file identification.
  2600. e_type - Stores the file type.
  2601. e_machine - Stores the machine architecture.
  2602. e_version - Stores the ELF format version.
  2603. e_entry - Stores the entry point.
  2604. e_phoff - Stores the program header file offset.
  2605. e_shoff - Stores the section header file offset.
  2606. e_flags - Stores architecture-specific flags.
  2607. e_ehsize - Stores the size of the ELF header in bytes.
  2608. e_phentsize - Stores the size of the program header entry.
  2609. e_phnum - Stores the size of the program header entries.
  2610. e_shentsize - Stores the size of a section header entry.
  2611. e_shnum - Stores the count of section header entries.
  2612. e_shstrndx - Stores the section name strings section.
  2613. --*/
  2614. typedef struct {
  2615. unsigned char e_ident[EI_NIDENT];
  2616. Elf64_Half e_type;
  2617. Elf64_Half e_machine;
  2618. Elf64_Word e_version;
  2619. Elf64_Addr e_entry;
  2620. Elf64_Off e_phoff;
  2621. Elf64_Off e_shoff;
  2622. Elf64_Word e_flags;
  2623. Elf64_Half e_ehsize;
  2624. Elf64_Half e_phentsize;
  2625. Elf64_Half e_phnum;
  2626. Elf64_Half e_shentsize;
  2627. Elf64_Half e_shnum;
  2628. Elf64_Half e_shstrndx;
  2629. } Elf64_Ehdr;
  2630. /*++
  2631. Structure Description:
  2632. This structure defines the ELF64 section header.
  2633. Members:
  2634. sh_name - Stores the index into the section header string table where the
  2635. section name string can bd found.
  2636. sh_type - Stores the section type.
  2637. sh_flags - Stores the section flags.
  2638. sh_addr - Stores the address in the memory image.
  2639. sh_offset - Stores the file offset of the section.
  2640. sh_size - Stores the size of the section in bytes.
  2641. sh_link - Stores the index of a related section.
  2642. sh_info - Stores a value that depends on the section type.
  2643. sh_addralign - Stores the alignment in bytes.
  2644. sh_entsize - Stores the size of each entry in the section.
  2645. --*/
  2646. typedef struct {
  2647. Elf64_Word sh_name;
  2648. Elf64_Word sh_type;
  2649. Elf64_Xword sh_flags;
  2650. Elf64_Addr sh_addr;
  2651. Elf64_Off sh_offset;
  2652. Elf64_Xword sh_size;
  2653. Elf64_Word sh_link;
  2654. Elf64_Word sh_info;
  2655. Elf64_Xword sh_addralign;
  2656. Elf64_Xword sh_entsize;
  2657. } Elf64_Shdr;
  2658. /*++
  2659. Structure Description:
  2660. This structure defines the ELF64 program header.
  2661. Members:
  2662. p_type - Stores the program header type.
  2663. p_flags - Stores access permission flags.
  2664. p_offset - Stores the file offset of the contents.
  2665. p_vaddr - Stores the virtual address in the memory image.
  2666. p_paddr - Stores the physical address (not used).
  2667. p_filesz - Stores the size of the contents within the file.
  2668. p_memsz - Stores the size of the contents in memory.
  2669. p_align - Stores the alignment in memory and in the file.
  2670. --*/
  2671. typedef struct {
  2672. Elf64_Word p_type;
  2673. Elf64_Word p_flags;
  2674. Elf64_Off p_offset;
  2675. Elf64_Addr p_vaddr;
  2676. Elf64_Addr p_paddr;
  2677. Elf64_Xword p_filesz;
  2678. Elf64_Xword p_memsz;
  2679. Elf64_Xword p_align;
  2680. } Elf64_Phdr;
  2681. /*++
  2682. Structure Description:
  2683. This structure defines the ELF64 dynamic section.
  2684. Members:
  2685. d_tag - Stores the entry type.
  2686. d_un - Stores a union of the two different forms of the value.
  2687. d_val - Stores the integer representation of the value.
  2688. d_ptr - Stores the pointer representation of the value.
  2689. --*/
  2690. typedef struct {
  2691. Elf64_Sxword d_tag;
  2692. union {
  2693. Elf64_Xword d_val;
  2694. Elf64_Addr d_ptr;
  2695. } d_un;
  2696. } Elf64_Dyn;
  2697. /*++
  2698. Structure Description:
  2699. This structure defines the ELF64 relocation entry that does not require
  2700. an addend.
  2701. Members:
  2702. r_offset - Stores the location to be relocated.
  2703. r_info - Stores the relocation type and symbol index.
  2704. --*/
  2705. typedef struct {
  2706. Elf64_Addr r_offset;
  2707. Elf64_Xword r_info;
  2708. } Elf64_Rel;
  2709. /*++
  2710. Structure Description:
  2711. This structure defines the ELF64 relocation entry that needs an addend
  2712. field.
  2713. Members:
  2714. r_offset - Stores the location to be relocated.
  2715. r_info - Stores the relocation type and symbol index.
  2716. r_addend - Stores the addend to throw in there.
  2717. --*/
  2718. typedef struct {
  2719. Elf64_Addr r_offset;
  2720. Elf64_Xword r_info;
  2721. Elf64_Sxword r_addend;
  2722. } Elf64_Rela;
  2723. typedef Elf_Note Elf64_Nhdr;
  2724. /*++
  2725. Structure Description:
  2726. This structure defines the ELF64 move entry.
  2727. Members:
  2728. m_value - Stores the symbol value.
  2729. m_info - Stores the size + index.
  2730. m_poffset - Stores the symbol offset.
  2731. m_repeat - Stores the repeat count.
  2732. m_stride - Stores the stride information.
  2733. --*/
  2734. typedef struct {
  2735. Elf64_Lword m_value;
  2736. Elf64_Xword m_info;
  2737. Elf64_Xword m_poffset;
  2738. Elf64_Half m_repeat;
  2739. Elf64_Half m_stride;
  2740. } Elf64_Move;
  2741. /*++
  2742. Structure Description:
  2743. This structure defines the ELF64 hardware/software capabilities array.
  2744. Members:
  2745. c_tag - Stores the tag which determines the interpretation of the value.
  2746. c_un - Stores a union of the two different forms of the value.
  2747. c_val - Stores the integer representation of the value.
  2748. c_ptr - Stores the pointer representation of the value.
  2749. --*/
  2750. typedef struct {
  2751. Elf64_Xword c_tag;
  2752. union {
  2753. Elf64_Xword c_val;
  2754. Elf64_Addr c_ptr;
  2755. } c_un;
  2756. } Elf64_Cap;
  2757. /*++
  2758. Structure Description:
  2759. This structure defines an ELF64 symbol table entry.
  2760. Members:
  2761. st_name - Stores the string table index of the name.
  2762. st_value - Stores the value of the symbol.
  2763. st_size - Stores the size of the associated objct.
  2764. st_info - Stores the type and binding information.
  2765. st_other - Stores a reserved value (not used).
  2766. st_shndx - Stores the section index of the symbol.
  2767. --*/
  2768. typedef struct {
  2769. Elf64_Word st_name;
  2770. unsigned char st_info;
  2771. unsigned char st_other;
  2772. Elf64_Half st_shndx;
  2773. Elf64_Addr st_value;
  2774. Elf64_Xword st_size;
  2775. } Elf64_Sym;
  2776. //
  2777. // Define structures used by Sun & GNU-style symbol versioning.
  2778. //
  2779. typedef struct {
  2780. Elf64_Half vd_version;
  2781. Elf64_Half vd_flags;
  2782. Elf64_Half vd_ndx;
  2783. Elf64_Half vd_cnt;
  2784. Elf64_Word vd_hash;
  2785. Elf64_Word vd_aux;
  2786. Elf64_Word vd_next;
  2787. } Elf64_Verdef;
  2788. typedef struct {
  2789. Elf64_Word vda_name;
  2790. Elf64_Word vda_next;
  2791. } Elf64_Verdaux;
  2792. typedef struct {
  2793. Elf64_Half vn_version;
  2794. Elf64_Half vn_cnt;
  2795. Elf64_Word vn_file;
  2796. Elf64_Word vn_aux;
  2797. Elf64_Word vn_next;
  2798. } Elf64_Verneed;
  2799. typedef struct {
  2800. Elf64_Word vna_hash;
  2801. Elf64_Half vna_flags;
  2802. Elf64_Half vna_other;
  2803. Elf64_Word vna_name;
  2804. Elf64_Word vna_next;
  2805. } Elf64_Vernaux;
  2806. typedef Elf64_Half Elf64_Versym;
  2807. typedef struct {
  2808. Elf64_Half si_boundto;
  2809. Elf64_Half si_flags;
  2810. } Elf64_Syminfo;
  2811. //
  2812. // -------------------------------------------------------------------- Globals
  2813. //
  2814. //
  2815. // -------------------------------------------------------- Function Prototypes
  2816. //