bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/28639] New: Fixing invalid build-id section size with --relocata


From: vchernou at cisco dot com
Subject: [Bug ld/28639] New: Fixing invalid build-id section size with --relocatable(-r) linker(ld) option
Date: Tue, 30 Nov 2021 17:00:45 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=28639

            Bug ID: 28639
           Summary: Fixing invalid build-id section size with
                    --relocatable(-r) linker(ld) option
           Product: binutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: vchernou at cisco dot com
  Target Milestone: ---

Created attachment 13809
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13809&action=edit
patch for fixing issue

building of glibc 2.32 and later with option "-Wl,--build-id" produce libc.so.6
with section ".note.gnu.build-id" that have invalid(double, 0x48) section size.
It happens because glibc use sublibraries for linking libc.so.
ld produce this sublibraries with build-id section and on last linking stage
loads this sections as input for linking.
ld should create new(valid) ".note.gnu.build-id" into function
ldelf_setup_build_id on last linking stage but it skip creating because
build-id section already exists.
As result libc.so.6 contain ".note.gnu.build-id" with build-ids from
sublibraries and without valid build-id
Howto solved:
Ignoring ".note.gnu.build-id" on linker input fix this problem.
Linker input doesn't have invalid build-id sections on ldelf_setup_build_id
stage and create new(proper) one for output library/binary

Clang have it's own fix for this issue:
https://reviews.llvm.org/D42823
https://bugs.llvm.org/show_bug.cgi?id=36203

howto reproduce:
yocto:
cd GLIBC_RECIPE_WORKDIR
export
CMD_PREFIX="./recipe-sysroot-native/usr/bin/x86_64-iosxe-linux/x86_64-iosxe-linux";
export GCC="$CMD_PREFIX-gcc"; export RELF="$CMD_PREFIX-readelf"
echo "void f1(){}" >f1.c
echo "void f2(){}" >f2.c
$GCC f1.c -c -o f1.o
$GCC f2.c -c -o f2.o
$GCC f1.o -Wl,--build-id -nostdlib -nostartfiles -r -o f1
$GCC f2.o -Wl,--build-id -nostdlib -nostartfiles -r -o f2
$GCC ./f1 ./f2 -shared -Wl,--build-id -nostdlib -nostartfiles -o f.so
$RELF -S f.so | grep -E -A1 "note.gnu.bu"

ubuntu:
echo "void f1(){}" >f1.c
echo "void f2(){}" >f2.c
gcc f1.c -c -o f1.o
gcc f2.c -c -o f2.o
gcc f1.o -Wl,--build-id -nostdlib -nostartfiles -r -o f1
gcc f2.o -Wl,--build-id -nostdlib -nostartfiles -r -o f2
gcc ./f1 ./f2 -shared -Wl,--build-id -nostdlib -nostartfiles -o f.so
readelf -S f.so | grep -E -A1 "note.gnu.bu"

output:
without fix
  [ 1] .note.gnu.bu[...] NOTE 0000000000000238  00000238
   0000000000000048  0000000000000000   A   0 0 4
with fix
  [ 1] .note.gnu.bu[...] NOTE 0000000000000238  00000238
   0000000000000024  0000000000000000   A   0 0 4

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]