From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14844 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: another armv7-m exception handling problem Date: Mon, 21 Oct 2019 01:20:05 -0400 Message-ID: <20191021052005.GF16318@brightrain.aerifal.cx> References: <20191021050411.GE16318@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="PyMzGVE0NRonI6bs" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="235530"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14860-gllmg-musl=m.gmane.org@lists.openwall.com Mon Oct 21 07:20:20 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1iMQ79-000zBd-OF for gllmg-musl@m.gmane.org; Mon, 21 Oct 2019 07:20:19 +0200 Original-Received: (qmail 30419 invoked by uid 550); 21 Oct 2019 05:20:17 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 30398 invoked from network); 21 Oct 2019 05:20:17 -0000 Content-Disposition: inline In-Reply-To: <20191021050411.GE16318@brightrain.aerifal.cx> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14844 Archived-At: --PyMzGVE0NRonI6bs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --PyMzGVE0NRonI6bs Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="weakref2.c" #include void foo(void) __attribute__((__weak__)); int main(void) { printf("%p\n", (void*)foo); } --PyMzGVE0NRonI6bs--