Discussion:
gold: No .debug_aranges section when linking with --gdb-index
Martin Richtarsky
2018-10-10 10:46:36 UTC
Permalink
Hi,

when I use gold with --gdb-index, the resulting binary is missing the
.debug_aranges section. The script below demonstrates the issue. lib1.so
is linked without --gdb-index and has .debug_aranges, but not
lib1_index.so. is this on purpose? .debug_aranges would be helpful for us
for fast callstack resolution.

Interestingly lld handles it differently (you can also test it with the
script below, just set the path to lld binutils)

Thanks and best regards,
Martin


#!/bin/bash

set -eu
# gold binutils
BINUTILS=-B/data/binutils-2.29.1/bin-gold
# lld
BINUTILS=-B/data/llvm7/bin-lld
GCC=/data/gcc-7.2.1/bin/
PATH=$GCC:$PATH

# Without gdb-index
g++ -c lib1.cpp -o lib1.o
g++ $BINUTILS -shared lib1.o -o lib1.so

# With gdb-index
g++ $BINUTILS -Wl,--gdb-index -shared lib1.o -o lib1_index.so

set -o xtrace
objdump -h lib1.so | grep aranges # has aranges with gold
objdump -h lib1_index.so | grep aranges # has no aranges with gold (but
with lld)
--
http://www.productive-cpp.com/
Loading...