[File] Detecting PIE binaries

Christos Zoulas christos at zoulas.com
Wed Jun 3 21:42:34 UTC 2020


I don't see it in mine!

christos

vmb1:~/src/file [5:39pm] 22#cc -pie -fPIE hello.c -o hello
vmb1:~/src/file [5:40pm] 23#readelf -d hello

Dynamic section at offset 0xaf0 contains 24 entries:
  Tag                Type                  Name/Value
 0x0000000000000001 NEEDED               Shared library: [libc.so.7]
 0x0000000000000015 DEBUG                0x0
 0x0000000000000007 RELA                 0x4f8
 0x0000000000000008 RELASZ               192 (bytes)
 0x0000000000000009 RELAENT              24 (bytes)
 0x000000006ffffff9 RELACOUNT            6
 0x0000000000000017 JMPREL               0x5b8
 0x0000000000000002 PLTRELSZ             144 (bytes)
 0x0000000000000003 PLTGOT               0x3cb8
 0x0000000000000014 PLTREL               RELA
 0x0000000000000006 SYMTAB               0x308
 0x000000000000000b SYMENT               24 (bytes)
 0x0000000000000005 STRTAB               0x48c
 0x000000000000000a STRSZ                103 (bytes)
 0x000000006ffffef5 GNU_HASH             0x418
 0x0000000000000004 HASH                 0x43c
 0x0000000000000019 INIT_ARRAY
 0x000000000000001b INIT_ARRAYSZ         8 (bytes)
 0x000000000000000c INIT                 0x1a2c
 0x000000000000000d FINI                 0x1a3c
 0x000000006ffffff0 VERSYM               0x3e0
 0x000000006ffffffe VERNEED              0x3f4
 0x000000006fffffff VERNEEDNUM           1
 0x0000000000000000 NULL                 0x0
vmb1:~/src/file [5:41pm] 24#uname -a
FreeBSD vmb1.astron.com 13.0-CURRENT FreeBSD 13.0-CURRENT #0 r361567: Thu May 28 04:59:08 UTC 2020     root at releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64


> On Jun 3, 2020, at 1:30 PM, Ed Maste <emaste at freebsd.org> wrote:
> 
> PIE binaries are currently (FreeBSD, file 5.38) reported as shared objects:
> 
> $ cc -fpie -pie -o hello hello.c
> $ /usr/local/bin/file hello
> 
> hello: ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD),
> dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.0
> (1300087), FreeBSD-style, with debug_info, not stripped
> 
> There is a .dynamic flag to indicate that the object is a PIE:
> 
> $ readelf -d hello
> 
> Dynamic section at offset 0xc20 contains 25 entries:
>  Tag                Type                  Name/Value
> 0x0000000000000001 NEEDED               Shared library: [libc.so.7]
> 0x000000006ffffffb FLAGS_1              PIE
> ...
> 
> Flag value:
> #define DF_1_PIE        0x08000000      /* Is position-independent executable */
> --
> File mailing list
> File at astron.com
> https://mailman.astron.com/mailman/listinfo/file

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <https://mailman.astron.com/pipermail/file/attachments/20200603/0dbdc50a/attachment.asc>


More information about the File mailing list