[Top][All Lists]

[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


            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
        .global call_it
    .cfi_personality 0x1b,nop_pers
    pushq       %rbp
    .cfi_def_cfa_offset 16
    .cfi_offset 6, -16
    movq        %rsp, %rbp
    call        do_unwind
    popq        %rbp
    .cfi_def_cfa 7, 8

===== 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";

extern "C" void call_it(void);

int main() {
  try {
  } 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
$ ./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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]