Corruption on a binary generated during packaging

Hello,

I have a package that build fine for years on Feodra. And now, on Fedora 42, the binary segfault and I am not able to load the debug symbols in gdb.
I suspect a corruption problem.
For Fedora 41, the messages related to debug symbolds extraction are the following:

find-debuginfo: starting
Extracting debug info from 7 files
DWARF-compressing 7 files

On Fedora 42, the messages are the following:

find-debuginfo: starting
Extracting debug info from 7 files
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.note.gnu.build-id' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.init' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.plt' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.plt.sec' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.text' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.fini' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.interp' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.gnu.hash' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.dynsym' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.gnu.version' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.gnu.version_r' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.rela.dyn' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.rela.plt' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.relr.dyn' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.rodata' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.eh_frame_hdr' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.eh_frame' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.gcc_except_table' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.note.gnu.property' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.note.ABI-tag' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.note.package' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.init_array' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.fini_array' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.data.rel.ro' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.got' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.data' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.dynstr' not in segment
objcopy: /builddir/build/BUILD/BespokeSynth-weekly-1.3.10-build/BUILDROOT/usr/bin/stBaNPZD: warning: allocated section `.dynamic' not in segment
DWARF-compressing 7 files

The link to the COPR build:

Is this a known problem ?

I tried both gcc and clang and the problem is the same.
I saw a build of a package with a failure during link … Don’t remember which one.

For this package, I used patchelf to add a RPATH. Maybe this tool is responsible of this problem. But this has worked for years too until Fedora 42.

Try the build with that step ommitted to see if your guess is good

Can’t you add an rpath with options in the link?

1 Like

So, I commented out the call to patchelf and after installing the package, I set the LD_LIBRARY_PATH, just to do the job done by patchelf and it worked.
So, patchelf is corrupting the binary …

Found that patchelf can corrupt binaries …

Found a solution: still using patchelf, but I uses mold as a linker instead of ld.
Used this cmake flag:

-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold" 

Why not use ld’s -rpath? From Using LD, the GNU linker - Options

-rpath dir
Add a directory to the runtime library search path. This is used when linking an ELF executable with shared objects. All -rpath arguments are concatenated and passed to the runtime linker, which uses them to locate shared objects at runtime. The -rpath option is also used when locating shared objects which are needed by shared objects explicitly included in the link; see the description of the -rpath-link option. If -rpath is not used when linking an ELF executable, the contents of the environment variableLD_RUN_PATH will be used if it is defined. The -rpath option may also be used on SunOS. By default, on SunOS, the linker will form a runtime search patch out of all the -Loptions it is given. If a -rpath option is used, the runtime search path will be formed exclusively using the -rpath options, ignoring the -L options. This can be useful when using gcc, which adds many -L options which may be on NFS mounted filesystems. For compatibility with other ELF linkers, if the -R option is followed by a directory name, rather than a file name, it is treated as the -rpath option.

1 Like