Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 793770 - sys-apps/portage: false positives on "QA Notice: Pre-stripped files found:" for files without ".symtab"
Summary: sys-apps/portage: false positives on "QA Notice: Pre-stripped files found:" f...
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 933986 784923 795810
  Show dependency tree
 
Reported: 2021-06-01 22:11 UTC by Sergei Trofimovich (RETIRED)
Modified: 2025-05-10 01:55 UTC (History)
4 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich (RETIRED) gentoo-dev 2021-06-01 22:11:58 UTC
In bug #784923 we found out that portage complains about pre-stripped files on glibc due to binutils-2.36 not emitting unused ".symtab". Executable exeample:

$ cat > crtn.S
        .section .init,"ax",@progbits
        addq $8, %rsp
        ret

        .section .fini,"ax",@progbits
        addq $8, %rsp
        ret

$ x86_64-pc-linux-gnu-gcc -O2 crtn.S -c -o crtn-2.36.o # -B/usr/x86_64-pc-linux-gnu/binutils-bin/2.35.2/
$ x86_64-pc-linux-gnu-gcc -O2 crtn.S -c -o crtn-2.35.o -B/usr/x86_64-pc-linux-gnu/binutils-bin/2.35.2/

$ scanelf -yqRBF '#k%F' -k '!.symtab' crtn-2.35.o crtn-2.36.o
crtn-2.36.o

Note: 2.36 file does not contain '.symtab' that portage expects as a proxy of unstripped binary:

https://gitweb.gentoo.org/proj/portage.git/tree/bin/estrip#n329
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2021-06-16 07:17:07 UTC
bug #795810 is another example where ELF file without program headers is slagged as "stripped". `readelf` complains on these files as:

"There are no program headers in this file."
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2021-06-16 07:32:54 UTC
Ideally `scanelf` should provide a mechanism for us to finter on files with program headers only. I don't think it has that as a one-liner.

I wonder if '#e' is expected to Just work. It does not today:

  $ scanelf -yqRBF '#e#k%F' -k '!.symtab' crtn-2.36.o
  crtn-2.36.o
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-13 06:42:37 UTC
(In reply to Sergei Trofimovich from comment #2)
> Ideally `scanelf` should provide a mechanism for us to finter on files with
> program headers only. I don't think it has that as a one-liner.
> 
> I wonder if '#e' is expected to Just work. It does not today:
> 
>   $ scanelf -yqRBF '#e#k%F' -k '!.symtab' crtn-2.36.o
>   crtn-2.36.o

Ah, it does not work as is because '#e#k' works as "any of", not "all of".
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2021-07-13 08:30:23 UTC
Also, absence of program headers is expected: It's not a final executable. We'll need a different, heuristic. Maybe, presence of non-empty executable PROGBITS sections:

  [ 1] .text             PROGBITS         0000000000000000  00000040
       0000000000000007  0000000000000000  AX       0     0     1
Comment 5 Arfrever Frehtes Taifersar Arahesis 2022-10-16 15:33:36 UTC
Later code in estrip uses 'file' to check type of file:
https://gitweb.gentoo.org/proj/portage.git/tree/bin/estrip?id=36dbd3e4336fa199a35b4f74c1679511707138f5#n492

	f=$(file "${x}") || exit 0
	...
	if [[ ${f} == *"current ar archive"* ]] ; then
		process_ar "${x}"
	elif [[ ${f} == *"SB executable"* || ${f} == *"SB pie executable"* ||
		${f} == *"SB shared object"* ]] ; then
		process_elf "${x}" "${inode_link}" ${PORTAGE_STRIP_FLAGS}
	elif [[ ${f} == *"SB relocatable"* ]] ; then
		process_elf "${x}" "${inode_link}" ${SAFE_STRIP_FLAGS}
	fi


So maybe earlier code in estrip (https://gitweb.gentoo.org/proj/portage.git/tree/bin/estrip?id=36dbd3e4336fa199a35b4f74c1679511707138f5#n406) should ignore *"SB relocatable"* files (i.e. *.o files)?
Comment 6 Larry the Git Cow gentoo-dev 2025-05-10 01:54:57 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ff1f410ec18385497f00dd86f2a64d60b1ed4b1a

commit ff1f410ec18385497f00dd86f2a64d60b1ed4b1a
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2025-05-10 01:52:52 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2025-05-10 01:53:27 +0000

    toolchain.eclass: set QA_PRESTRIPPED for now for Go
    
    As slyfox analysed on the bug, Portage shouldn't be warning on these
    files as they're not executables. We should look at fixing Portage
    but set QA_PRESTRIPPED for now to avoid noise and potentially missing
    other actual warnings.
    
    Bug: https://bugs.gentoo.org/793770
    Closes: https://bugs.gentoo.org/795810
    Closes: https://bugs.gentoo.org/955240
    Signed-off-by: Sam James <sam@gentoo.org>

 eclass/toolchain.eclass | 2 ++
 1 file changed, 2 insertions(+)