On Mon, Oct 21, 2019 at 01:04:11AM -0400, Rich Felker wrote: > On Mon, Oct 21, 2019 at 03:43:40PM +1100, Patrick Oppenlander wrote: > > Not sure if this is a musl, gcc or ld bug. > > > > Running gcc-8.3.0 musl 1.1.24 static pie. > > > > Simple test case: > > > > int main() > > { > > try { > > throw 1; > > } catch (int d) { > > return d; > > } > > return 0; > > } > > > > Expected: > > % ./a.out > > % echo $? > > 1 > > > > Actual: > > % ./a.out > > terminate called after throwing an instance of 'int' > > terminate called recursively > > Aborted (core dumped) > > > > The problem is that get_eit_entry is returning _URC_FAILURE here: > > > > if (__gnu_Unwind_Find_exidx) > > { > > eitp = (const __EIT_entry *) __gnu_Unwind_Find_exidx (return_address, > > &nrec); > > if (!eitp) > > { > > UCB_PR_ADDR (ucbp) = 0; > > return _URC_FAILURE; <----- !!!! > > } > > } > > > > Looks like a linker or program load problem to me -- the GOT entry for > > __gnu_Unwind_Find_exidx is correctly set to 0, but after program load > > it's been offset to some non-zero value. There's an R_ARM_RELATIVE > > relocation on the GOT entry. > > > > Not sure where this is going wrong. > > OK, this is almost surely a bug in the tooling -- a weak reference has > to use a GOT slot in PIC since it might be undefined and need to > evaluate to 0, and the GOT slot should not have a relocation on it if > it ends up evaluating to 0. Pretty sure it's ld's fault. I can reproduce it with the attached trivial GNU C program. Rich