diff --git a/libwild/src/elf_writer.rs b/libwild/src/elf_writer.rs index ba58fd3f5..4a3dad2af 100644 --- a/libwild/src/elf_writer.rs +++ b/libwild/src/elf_writer.rs @@ -1860,6 +1860,7 @@ fn write_symbols<'data>( if let Some(section_index) = object.object.symbol_section(sym, sym_index)? { match &object.sections[section_index.0] { SectionSlot::Loaded(section) => section.output_section_id(), + SectionSlot::LoadedDebugInfo(section) => section.output_section_id(), SectionSlot::MergeStrings(section) => section.part_id.output_section_id(), SectionSlot::FrameData(..) => output_section_id::EH_FRAME, _ => bail!( diff --git a/wild/tests/external_tests/mold_skip_tests.toml b/wild/tests/external_tests/mold_skip_tests.toml index 2ac85bb7d..35cf5dc38 100644 --- a/wild/tests/external_tests/mold_skip_tests.toml +++ b/wild/tests/external_tests/mold_skip_tests.toml @@ -27,7 +27,6 @@ tests = [ "oformat-binary.sh", "omagic.sh", "package-metadata.sh", - "relocatable-debug-info.sh", "relocatable-exception.sh", "relocatable-merge-sections.sh", "repro.sh", # Note in this test's second half that it uses a custom environment variable called `MOLD_REPRO`. While Wild currently doesn't support `--repro`, it will eventually be moved to the "ignore" group once support is added. diff --git a/wild/tests/sources/elf/linker-plugin-lto-debug-info/linker-plugin-lto-debug-info.c b/wild/tests/sources/elf/linker-plugin-lto-debug-info/linker-plugin-lto-debug-info.c new file mode 100644 index 000000000..a30c7b712 --- /dev/null +++ b/wild/tests/sources/elf/linker-plugin-lto-debug-info/linker-plugin-lto-debug-info.c @@ -0,0 +1,24 @@ +//#AbstractConfig:default +//#RequiresLinkerPlugin:true +//#RequiresCompilerFlags:-flto=auto -fno-fat-lto-objects +//#DiffEnabled:false +//#RunEnabled:false +//#SkipLinker:ld + +//#Config:gcc:default +//#CompArgs:-O2 -g -DRELDEBUG -flto=auto -fno-fat-lto-objects +//#Object:runtime.c +//#LinkerDriver:gcc +//#LinkArgs:-flto=auto -nostdlib -Wl,--export-dynamic -rdynamic +//#ExpectSym:debug_sym section=".debug_info" + +#include "runtime.h" + +int debug_sym __attribute__((used, section(".debug_info"))) = 123; + +int foo() { return 42; } + +void _start(void) { + runtime_init(); + exit_syscall(foo()); +} diff --git a/wild/tests/sources/elf/relocatables/relocatables.c b/wild/tests/sources/elf/relocatables/relocatables.c index ebf7c1733..f60b864c5 100644 --- a/wild/tests/sources/elf/relocatables/relocatables.c +++ b/wild/tests/sources/elf/relocatables/relocatables.c @@ -1,5 +1,6 @@ //#EnableLinker:lld //#Object:runtime.c +//#CompArgs:-g //#Relocatable:relocatable-1.c,relocatable-2.c #include "runtime.h"