95 #define INFO( s )
print "objinfo: " + s
165 dim shared as ubyte elfmagic(0
to 15) = _
167 &h7f, &h45, &h4c, &h46, 0, &h01, _
168 &h01, &h00, &h00, &h00, &h00, &h00 _
207 #macro ELFLOADINGCODE(ELF_H, ELF_SH, ELF_MAGIC_4, ELF_MACHINE)
209 private function hCheck##ELF_SH _
211 byval h
as ELF_H
ptr, _
212 byval index
as integer _
215 dim as ELF_SH
ptr sh =
any
216 dim as integer headeroffset =
any
218 headeroffset = h->
e_shoff + (index *
sizeof( ELF_SH ))
221 if( (
culngint( headeroffset ) +
sizeof( ELF_SH )) >
objdata.
size )
then
222 INFO(
"elf: no room for section header" )
226 sh =
cptr(
any ptr,
objdata.
p ) + headeroffset
230 INFO(
"elf: invalid sh_offset/sh_size fields" )
237 private function hGetSectionName##ELF_SH _
239 byval h
as ELF_H
ptr, _
240 byval index
as integer, _
241 byval nametb
as integer _
244 const MAXNAMELEN = 32
245 static as zstring * MAXNAMELEN+1 sectionname
247 dim as ELF_SH
ptr sh =
any
248 dim as integer i =
any, j =
any, ch =
any
250 sh = hCheck##ELF_SH( h, index )
270 function = @sectionname
273 private sub hLoadFbctinfFrom##ELF_H( )
274 dim as ELF_H
ptr h =
any
275 dim as ELF_SH
ptr sh =
any, nametb =
any
276 dim as zstring ptr sectionname =
any
282 INFO(
"elf: no room for main header" )
289 for i as integer = 0
to 15
291 INFO(
"elf: magic mismatch" )
297 if( h->
e_ehsize <>
sizeof( ELF_H ) )
then
298 INFO(
"elf: header size mismatch" )
304 INFO(
"elf: not a relocatable .o" )
310 INFO(
"elf: machine mismatch" )
316 INFO(
"elf: invalid e_shentsize" )
322 INFO(
"elf: invalid e_shnum" )
328 INFO(
"elf: invalid e_shstrndx" )
334 INFO(
"elf: invalid e_shoff" )
341 if( nametb = NULL )
then
342 INFO(
"elf: can't read string table" )
348 for i as integer = 1
to h->
e_shnum - 1
349 sectionname = hGetSectionName##ELF_SH( h,
i, nametb->
sh_offset )
350 if( sectionname )
then
351 INFO(
"elf: seeing section '" + *sectionname +
"'" )
353 sh = hCheck##ELF_SH( h,
i )
383 name(0
to 7)
as ubyte
397 dim as COFF_SH ptr sh =
any, shbase =
any
403 INFO(
"coff: no room for main header" )
411 INFO(
"coff: magic mismatch" )
417 INFO(
"coff: optheadsize field <> 0" )
423 INFO(
"coff: no room for section header table" )
427 shbase =
cptr(
any ptr, h ) +
sizeof(
COFF_H )
429 for i as integer = 0
to (h->
seccount - 1)
433 dim temp
as zstring * 9
434 for j
as integer = 0
to 7
435 temp[j] = sh->
name(j)
437 INFO(
"coff: seeing section '" + temp +
"'" )
444 for j
as integer = 0
to 7
451 INFO(
"coff: invalid section header data offset" )
464 name(0
to 15)
as ubyte
468 mode(0
to 7)
as ubyte
469 size(0
to 9)
as ubyte
470 magic(0
to 1)
as ubyte
473 dim shared as ubyte armagic(0
to 7) = _
475 asc(
"!" ),
asc(
"<" ),
asc(
"a" ),
asc(
"r" ), _
476 asc(
"c" ),
asc(
"h") ,
asc(
">" ),
asc( !
"\n" ) _
481 byval p as ubyte ptr, _
482 byval length
as integer _
487 static as zstring * MAXLEN+1 s
488 dim as integer last =
any,
i =
any
490 assert( length <= MAXLEN )
495 if(
p[last] <>
asc(
" " ) )
then
513 dim as AR_H ptr h =
any
515 dim as integer i =
any, filesize =
any
542 INFO(
"ar: found " +
filename +
", " +
str( filesize ) +
" bytes" )
544 if( filesize < 0 )
then
555 case "__fb_ct.inf",
"__fb_ct.inf/"
556 if( filesize > 0 )
then
562 case "/",
"//",
"__.SYMDEF"
587 dim as integer f =
any,
size =
any
588 dim as ubyte ptr p =
any
594 if(
open(
filename,
for binary,
access read,
as #f ) <> 0 )
then
595 INFO(
"file not found: " +
filename )
603 if(
get( #f, , *
p,
size,
size ) <> 0 )
then
614 select case as const(
fbGetOption( FB_COMPOPT_TARGET ) )
615 case FB_COMPTARGET_CYGWIN, FB_COMPTARGET_DOS, _
616 FB_COMPTARGET_WIN32, FB_COMPTARGET_XBOX
617 if( fbCpuTypeIs64bit( ) )
then
625 case FB_COMPTARGET_DARWIN, FB_COMPTARGET_FREEBSD, _
626 FB_COMPTARGET_LINUX, FB_COMPTARGET_NETBSD, _
627 FB_COMPTARGET_OPENBSD
628 if( fbCpuTypeIs64bit( ) )
then
630 hLoadFbctinfFromELF64_H( )
633 hLoadFbctinfFromELF32_H( )
639 INFO(
"no .fbctinf found" )
643 INFO(
"found .fbctinf (" +
str(
fbctinf.
size ) +
" bytes)" )
647 INFO(
".fbctinf is using the old format" )
667 ( @
"-mt" , FALSE ), _
715 sub objinfoReadLib(
byref libname
as string,
byval libpaths
as TLIST
ptr )
717 dim as TSTRSETITEM
ptr path =
any
725 libfile = path->s + FB_HOST_PATHDIV +
filename
734 if( path = NULL )
then
735 INFO(
"could not find library: " + libname )
743 dim as integer begin =
any
802 INFO(
"lib: " + dat )
805 INFO(
"libpath: " + dat )
806 return OBJINFO_LIBPATH
812 if(
len( dat ) > 0 )
then
813 INFO(
"-lang " + dat )
859 function objinfoEncode(
byval entry
as integer )
as zstring ptr