Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 793770

Summary: sys-apps/portage: false positives on "QA Notice: Pre-stripped files found:" for files without ".symtab"
Product: Portage Development Reporter: Sergei Trofimovich (RETIRED) <slyfox>
Component: CoreAssignee: Portage team <dev-portage>
Status: CONFIRMED ---    
Severity: normal CC: slyfox, toolchain
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=847493
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 795810, 784923    

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)?