[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gold/22724] New: gold: --gc-sections needs to preserve DWARF person
From: |
benjamin at benjamin dot pe |
Subject: |
[Bug gold/22724] New: gold: --gc-sections needs to preserve DWARF personality functions |
Date: |
Wed, 17 Jan 2018 12:38:06 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=22724
Bug ID: 22724
Summary: gold: --gc-sections needs to preserve DWARF
personality functions
Product: binutils
Version: 2.29
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gold
Assignee: ccoutant at gmail dot com
Reporter: benjamin at benjamin dot pe
CC: ian at airs dot com
Target Milestone: ---
This is a bit odious to reproduce because C compilers don't easily let you pick
a custom personality. I need two files, tramp.s and main.cc:
===== tramp.s
.text
.global call_it
call_it:
.cfi_startproc
.cfi_personality 0x1b,nop_pers
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
call do_unwind
nop
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
===== main.cc
#include <iostream>
#include <unwind.h>
extern "C" void do_unwind(void) {
throw new std::exception();
}
extern "C" __attribute__((visibility("hidden"))) _Unwind_Reason_Code nop_pers(
int version,
_Unwind_Action actions,
_Unwind_Exception_Class exception_class,
struct _Unwind_Exception *ue_header,
struct _Unwind_Context *context) {
std::cout << "running personality\n";
return _URC_CONTINUE_UNWIND;
}
extern "C" void call_it(void);
int main() {
try {
call_it();
} catch (...) {
std::cout << "caught exception!\n";
return 0;
}
std::cerr << "failed\n";
return 1;
}
Now, notice the difference between GNU ld and gold:
$ g++ -ffunction-sections -O2 tramp.s main.cc -o repro -Wl,--gc-sections
$ ./repro
running personality
running personality
caught exception!
$ g++ -ffunction-sections -O2 tramp.s main.cc -o repro -Wl,--gc-sections
-fuse-ld=gold
$ ./repro
Segmentation fault (core dumped)
--print-gc-sections reveals this is because the nop_pers function is being
deleted by gold.
gold will preserve any section containing "personality" in the name. But I
don't believe including "personality" in the name of a personality function is
any more than a convention. For example, luajit defines a personality routine
named lj_err_unwind_dwarf.
--
You are receiving this mail because:
You are on the CC list for the bug.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug gold/22724] New: gold: --gc-sections needs to preserve DWARF personality functions,
benjamin at benjamin dot pe <=