mold
mold copied to clipboard
[RISCV64] Segfault with __attribute__ ((section (".xxx")))
cat <<EOF | $CC -O2 -o $t/a.o -c -xc -
int a __attribute__ ((section (".low"))) = 42;
int main () {
return a;
}
EOF
$CC -B. -Wl,--section-start=.low=0x16 -nostdlib -O2 -o $t/exe $t/a.o
Backtrace with gdb mold and on_complete = fork_child(); commented out.
r --thread-count=1 -plugin /usr/lib/gcc-cross/riscv64-linux-gnu/10/liblto_plugin.so -plugin-opt=/usr/lib/gcc-cross/riscv64-linux-gnu/10/lto-wrapper -plugin-opt=-fresolution=/tmp/ccRTH3k5.res --sysroot=/ --build-id --eh-frame-hdr -hash-style=gnu --as-needed -melf64lriscv -dynamic-linker /lib/ld-linux-riscv64-lp64d.so.1 -pie -z now -z relro -o out/test/elf/riscv64/riscv-clui/exe -L. -L/usr/lib/gcc-cross/riscv64-linux-gnu/10 -L/usr/lib/gcc-cross/riscv64-linux-gnu/10/../../../../riscv64-linux-gnu/lib -L/lib/riscv64-linux-gnu -L/usr/lib/riscv64-linux-gnu --section-start=.low=0x16 out/test/elf/riscv64/riscv-clui/a.o
#1 0x0000557cc4078388 in mold::elf::InputSection<mold::elf::RISCV64>::copy_contents_riscv (this=0x22ee40d0780, ctx=...,
buf=0x7f8ef8a2a000 "\177ELF\002\001\001") at elf/arch-riscv.cc:625
#2 0x0000557cc414870b in mold::elf::InputSection<mold::elf::RISCV64>::write_to (this=0x22ee40d0780, ctx=...,
buf=0x7f8ef8a2a000 "\177ELF\002\001\001") at elf/input-sections.cc:288
#3 0x0000557cc4235287 in mold::elf::OutputSection<mold::elf::RISCV64>::write_to(mold::elf::Context<mold::elf::RISCV64>&, unsigned char*)::{lambda(long)#1}::operator()(long) const (this=0x22ee40e2600, i=1) at elf/output-chunks.cc:865
#4 0x0000557cc4332636 in tbb::detail::d1::parallel_for_body_wrapper<mold::elf::OutputSection<mold::elf::RISCV64>::write_to(mold::elf::Context<mold::elf::RISCV64>&, unsigned char*)::{lambda(long)#1}, long>::operator()(tbb::detail::d1::blocked_range<long> const&) const (this=0x22ee4170758, r=...) at third-party/tbb/include/tbb/../oneapi/tbb/parallel_for.h:208