Skip to content

Commit 7fb9e83

Browse files
committed
abnativeelf: strip GCC LTO data from static libraries
1 parent 2d2870b commit 7fb9e83

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

native/abnativeelf.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ int elf_copy_debug_symbols(const char *src_path, const char *dst_path,
584584
return -1;
585585
}
586586
FileLockGuard lock{fd};
587-
struct stat st {};
587+
struct stat st{};
588588
if (fstat(fd, &st) < 0) {
589589
perror("fstat");
590590
return -1;
@@ -643,6 +643,8 @@ int elf_copy_debug_symbols(const char *src_path, const char *dst_path,
643643
case BinaryType::Static:
644644
// skip static library
645645
flags |= AB_ELF_STRIP_ONLY;
646+
args.emplace_back("-R");
647+
args.emplace_back(".gnu.lto*");
646648
break;
647649
case BinaryType::Executable:
648650
// strip all symbols
@@ -705,8 +707,9 @@ int elf_copy_debug_symbols(const char *src_path, const char *dst_path,
705707
}
706708
if (!(flags & AB_ELF_STRIP_ONLY)) {
707709
const auto path = final_path.string();
708-
const char *args[] = {"objcopy", "--only-keep-debug", src_path,
709-
path.c_str(), nullptr};
710+
const char *args[] = {
711+
"objcopy", "--only-keep-debug", "--compress-debug-sections=zstd",
712+
src_path, path.c_str(), nullptr};
710713
int ret = forked_execvp("objcopy", const_cast<char *const *>(args));
711714
if (ret != 0) {
712715
return ret;

0 commit comments

Comments
 (0)