1
0

elf.h 62 KB

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