Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 686282 - estrip should strip __gentoo_check_ldflags__ symbol from *.o files
Summary: estrip should strip __gentoo_check_ldflags__ symbol from *.o files
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 686768
  Show dependency tree
 
Reported: 2019-05-19 04:29 UTC by Arfrever Frehtes Taifersar Arahesis
Modified: 2019-08-01 19:20 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch (portage.patch,969 bytes, patch)
2019-05-19 05:03 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arfrever Frehtes Taifersar Arahesis 2019-05-19 04:29:19 UTC
estrip should strip __gentoo_check_ldflags__ symbol from *.o files.

The main problem caused by not doing it is deceiving QA check for respectation of LDFLAGS in executables.

sys-libs/glibc installs several *crt*.o files. A part of them are created using linker with -r option which is used to create *.o files (often from other *.o files). And sys-libs/glibc somehow respects LDFLAGS (at least when creating these *.o files). QA check for respectation of LDFLAGS is enabled if -Wl,--defsym=__gentoo_check_ldflags__=${some_value} is used, which adds __gentoo_check_ldflags__ symbol to these *.o files:

# nm /usr/lib64/crt1.o | grep __gentoo_check_ldflags__
0000000000000000 A __gentoo_check_ldflags__
# nm /usr/lib64/Scrt1.o | grep __gentoo_check_ldflags__
0000000000000000 A __gentoo_check_ldflags__
# nm /usr/lib64/gcrt1.o | grep __gentoo_check_ldflags__
0000000000000000 A __gentoo_check_ldflags__
# 

This __gentoo_check_ldflags__ symbol is inherited by executables (but not shared libraries), so even when they do not respect LDFLAGS, they would not be detected by QA check:

# gcc -shared -fPIC -o /tmp/test_1.so -x c /dev/null
# gcc -o /tmp/test_1 -x c - <<< "int main(){}"
# strip -N __gentoo_check_ldflags__ /usr/lib64/Scrt1.o
# gcc -shared -fPIC -o /tmp/test_2.so -x c /dev/null
# gcc -o /tmp/test_2 -x c - <<< "int main(){}"
# nm /tmp/test_1.so | grep __gentoo_check_ldflags__
# nm /tmp/test_2.so | grep __gentoo_check_ldflags__
# nm /tmp/test_1 | grep __gentoo_check_ldflags__
0000000000000000 A __gentoo_check_ldflags__
# nm /tmp/test_2 | grep __gentoo_check_ldflags__
# scanelf -qyRF '#k%p' -k .dynsym /tmp/test_{1,2}{,.so}
/tmp/test_1
/tmp/test_1.so
/tmp/test_2
/tmp/test_2.so
# scanelf -qyRF '#s%p' -s __gentoo_check_ldflags__ /tmp/test_{1,2}{,.so}
/tmp/test_1
# 

(In this example, __gentoo_check_ldflags__ symbol is deleted from Scrt1.o before creation of test_2*.)


Currently used invocation of `strip` would not strip random unneeded symbols from *.o files:

# gcc -nostdlib -r -o /tmp/test_3.o -Wl,--defsym=XXXX=1234 -x c - <<< "int main(){}"
# gcc -o /tmp/test_3 -Wl,--defsym=XXXX=1234 -x c - <<< "int main(){}"
# nm /tmp/test_3.o | grep XXXX
00000000000004d2 A XXXX
# nm /tmp/test_3 | grep XXXX
00000000000004d2 A XXXX
# strip --strip-unneeded /tmp/test_3{.o,}
# nm /tmp/test_3.o | grep XXXX
00000000000004d2 A XXXX
# nm /tmp/test_3 | grep XXXX
nm: /tmp/test_3: no symbols
# nm -D /tmp/test_3 | grep XXXX
#
Comment 1 Arfrever Frehtes Taifersar Arahesis 2019-05-19 05:03:51 UTC
Created attachment 577252 [details, diff]
Patch
Comment 2 Larry the Git Cow gentoo-dev 2019-05-20 05:09:10 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=86f211e3a552753eb945670a39c1a3b14c3c3bd1

commit 86f211e3a552753eb945670a39c1a3b14c3c3bd1
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
AuthorDate: 2019-05-19 05:01:06 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2019-05-20 05:08:41 +0000

    estrip: Strip __gentoo_check_ldflags__ symbol.
    
    Bug: https://bugs.gentoo.org/686282
    Signed-off-by: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 bin/estrip | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)