|
81 | 81 | '' hLoadFbctinfFromObj(): |
82 | 82 | '' reads the currently loaded object file, |
83 | 83 | '' using either the COFF (Win32, DOS) or ELF32 (Linux, *BSD) format. |
| 84 | +'' ELF32 (linux-arm) or ELF64 (linux-aarch64) |
84 | 85 | '' looks for the .fbctinf section, |
85 | 86 | '' and if found, parses its content, and tells the frontend about the |
86 | 87 | '' found libraries etc. by using the callbacks. |
@@ -166,12 +167,14 @@ end type |
166 | 167 | dim shared as ubyte elfmagic(0 to 15) = _ |
167 | 168 | { _ |
168 | 169 | &h7f, &h45, &h4c, &h46, 0, &h01, _ '' index 4 is set to 1 (32bit) or 2 (64bit) |
169 | | - &h01, &h00, &h00, &h00, &h00, &h00 _ |
| 170 | + &h01, &h00, &h00, &h00, &h00, &h00 _ '' index 12 is set to machine |
170 | 171 | } |
171 | 172 |
|
172 | 173 | const ET_REL = 1 |
173 | 174 | const EM_386 = 3 |
174 | | -const EM_X86_64 = 62 |
| 175 | +const EM_X86_64 = &h3e |
| 176 | +const EM_ARM32 = &h28 |
| 177 | +const EM_AARCH64 = &hb7 |
175 | 178 |
|
176 | 179 | '' ELF section headers |
177 | 180 | type ELF32_SH field = 1 |
@@ -205,7 +208,7 @@ end type |
205 | 208 | '' different field offsets and sizes), and there are a few constant values that |
206 | 209 | '' are different too. |
207 | 210 |
|
208 | | -#macro ELFLOADINGCODE(ELF_H, ELF_SH, ELF_MAGIC_4, ELF_MACHINE) |
| 211 | +#macro ELFLOADINGCODE(ELF_H, ELF_SH, ELF_MAGIC_4) |
209 | 212 |
|
210 | 213 | private function hCheck##ELF_SH _ |
211 | 214 | ( _ |
@@ -271,7 +274,7 @@ private function hGetSectionName##ELF_SH _ |
271 | 274 | function = @sectionname |
272 | 275 | end function |
273 | 276 |
|
274 | | -private sub hLoadFbctinfFrom##ELF_H( ) |
| 277 | +private sub hLoadFbctinfFrom##ELF_H( byval ELF_MACHINE as integer ) |
275 | 278 | dim as ELF_H ptr h = any |
276 | 279 | dim as ELF_SH ptr sh = any, nametb = any |
277 | 280 | dim as zstring ptr sectionname = any |
@@ -306,7 +309,7 @@ private sub hLoadFbctinfFrom##ELF_H( ) |
306 | 309 | exit sub |
307 | 310 | end if |
308 | 311 |
|
309 | | - '' x86/x86_64? |
| 312 | + '' x86/x86_64/arm/aarch64? |
310 | 313 | if( h->e_machine <> ELF_MACHINE ) then |
311 | 314 | INFO( "elf: machine mismatch" ) |
312 | 315 | exit sub |
@@ -364,8 +367,8 @@ end sub |
364 | 367 |
|
365 | 368 | #endmacro |
366 | 369 |
|
367 | | -ELFLOADINGCODE( ELF32_H, ELF32_SH, 1, EM_386 ) |
368 | | -ELFLOADINGCODE( ELF64_H, ELF64_SH, 2, EM_X86_64 ) |
| 370 | +ELFLOADINGCODE( ELF32_H, ELF32_SH, 1 ) |
| 371 | +ELFLOADINGCODE( ELF64_H, ELF64_SH, 2 ) |
369 | 372 |
|
370 | 373 | '' COFF main header |
371 | 374 | type COFF_H field = 1 |
@@ -625,10 +628,16 @@ private sub hLoadFbctinfFromObj( ) |
625 | 628 | select case( fbGetCpuFamily( ) ) |
626 | 629 | case FB_CPUFAMILY_X86_64 |
627 | 630 | INFO( "reading x86-64 ELF: " + parser.filename ) |
628 | | - hLoadFbctinfFromELF64_H( ) |
| 631 | + hLoadFbctinfFromELF64_H( EM_X86_64 ) |
629 | 632 | case FB_CPUFAMILY_X86 |
630 | 633 | INFO( "reading i386 ELF: " + parser.filename ) |
631 | | - hLoadFbctinfFromELF32_H( ) |
| 634 | + hLoadFbctinfFromELF32_H( EM_386 ) |
| 635 | + case FB_CPUFAMILY_AARCH64 |
| 636 | + INFO( "reading aarch64 ELF: " + parser.filename ) |
| 637 | + hLoadFbctinfFromELF64_H( EM_AARCH64 ) |
| 638 | + case FB_CPUFAMILY_ARM |
| 639 | + INFO( "reading arm32 ELF: " + parser.filename ) |
| 640 | + hLoadFbctinfFromELF32_H( EM_ARM32 ) |
632 | 641 | end select |
633 | 642 | end if |
634 | 643 |
|
|
0 commit comments