View Issue Details

IDProjectCategoryView StatusLast Update
0000183fileGeneralpublic2020-08-22 18:04
Reporterliuzhiqiang Assigned Tochristos  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version5.39 
Fixed in Version5.40 
Summary0000183: “PR 93:file incorrectly recognizes -static-pie binaries” should be reopened.
Description“PR 93:file incorrectly recognizes -static-pie binaries”should be reopened.

To solve “PR 93:file incorrectly recognizes -static-pie binaries”, one patch (24c9c086cd7c5) is introduced in v5.38.

However, the patch will lead to a new problem, "file incorrectly recognizes shared objects" problem. So, patch (028a15617a7f)
is created to undo the patch (24c9c086cd7c5) to solve "file incorrectly recognizes shared objects" problem.

Finally, "file incorrectly recognizes shared objects" problem is solved, while “PR 93:file incorrectly recognizes -static-pie binaries”problem
occurs again. So we need to solve it.

“PR 93:file incorrectly recognizes -static-pie binaries”: https://bugs.astron.com/view.php?id=93
Steps To Reproducefile version: v5.39
details can be found in https://bugs.astron.com/view.php?id=93.


    1. Create a simple hello word C program
2. Compile it using gcc -fPIE -static-pie -o test test.c
3. Run file on the resulting binary

Output:

test: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=4594afb38f3f60aaad10d08ab519fcaeae55ee70, for GNU/Linux 3.2.0, not stripped

It should actually be reported as statically linked, check with ldd:

$ ldd test
    statically linked
TagsNo tags attached.

Activities

christos

2020-08-22 14:30

manager   ~0003449

Well, this is because static-pie binaries are special... (In order to be loaded anywhere they have a dynamic section).

1. run 'readelf -d test': A dynamic section in a static binary?
2. run 'gcc -fPIE -static -static-pie -o test test.c': oops it does not work :-)
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a PIE object
collect2: error: ld returned 1 exit status

I guess file detection can be improved

christos

2020-08-22 18:04

manager   ~0003450

Fixed, thanks. It will now call them "static-pie linked".

Issue History

Date Modified Username Field Change
2020-08-18 09:37 liuzhiqiang New Issue
2020-08-22 14:16 christos Assigned To => christos
2020-08-22 14:16 christos Status new => assigned
2020-08-22 14:30 christos Status assigned => feedback
2020-08-22 14:30 christos Note Added: 0003449
2020-08-22 14:31 christos Status feedback => acknowledged
2020-08-22 18:04 christos Status acknowledged => resolved
2020-08-22 18:04 christos Resolution open => fixed
2020-08-22 18:04 christos Fixed in Version => 5.40
2020-08-22 18:04 christos Note Added: 0003450