* [PATCH] xtensa: fix localized symbol refcounting with --gc-sections
@ 2015-05-14 2:50 Max Filippov
2015-05-14 3:58 ` augustine.sterling
0 siblings, 1 reply; 3+ messages in thread
From: Max Filippov @ 2015-05-14 2:50 UTC (permalink / raw)
To: binutils
Cc: Sterling Augustine, David Weatherford, Marc Gauthier,
linux-xtensa, Max Filippov
elf_xtensa_gc_sweep_hook doesn't correctly unreference symbols that were
made local, that results in link failure with the following message:
BFD (GNU Binutils) 2.24 internal error, aborting at elf32-xtensa.c line
3372 in elf_xtensa_finish_dynamic_sections
elf_xtensa_gc_sweep_hook determines symbol reference type (PLT or GOT) by
relocation type. Relocation types are not changed when symbol becomes
local, but its PLT references are added to GOT references and
plt.refcount is set to 0. Such symbol cannot be unreferences in the
elf_xtensa_gc_sweep_hook and its extra references make calculated GOT
relocations section size not match number of GOT relocations.
Fix it by treating PLT reference as GOT reference when plt.refcount is
not positive.
2015-05-14 Max Filippov <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Treat PLT reference
as GOT reference when plt.refcount is not positive.
---
bfd/elf32-xtensa.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 53af1c6..2523670 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -1360,10 +1360,14 @@ elf_xtensa_gc_sweep_hook (bfd *abfd,
{
if (is_plt)
{
+ /* If the symbol has been localized its plt.refcount got moved
+ to got.refcount. Handle it as GOT. */
if (h->plt.refcount > 0)
h->plt.refcount--;
+ else
+ is_got = TRUE;
}
- else if (is_got)
+ if (is_got)
{
if (h->got.refcount > 0)
h->got.refcount--;
--
1.8.1.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xtensa: fix localized symbol refcounting with --gc-sections
2015-05-14 2:50 [PATCH] xtensa: fix localized symbol refcounting with --gc-sections Max Filippov
@ 2015-05-14 3:58 ` augustine.sterling
2015-05-14 4:10 ` Max Filippov
0 siblings, 1 reply; 3+ messages in thread
From: augustine.sterling @ 2015-05-14 3:58 UTC (permalink / raw)
To: Max Filippov; +Cc: binutils, David Weatherford, Marc Gauthier, linux-xtensa
On Wed, May 13, 2015 at 7:49 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> 2015-05-14 Max Filippov <jcmvbkbc@gmail.com>
> bfd/
> * elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Treat PLT reference
> as GOT reference when plt.refcount is not positive.
This is OK, please apply.
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xtensa: fix localized symbol refcounting with --gc-sections
2015-05-14 3:58 ` augustine.sterling
@ 2015-05-14 4:10 ` Max Filippov
0 siblings, 0 replies; 3+ messages in thread
From: Max Filippov @ 2015-05-14 4:10 UTC (permalink / raw)
To: augustine.sterling
Cc: binutils, David Weatherford, Marc Gauthier, linux-xtensa
On Thu, May 14, 2015 at 6:58 AM, augustine.sterling@gmail.com
<augustine.sterling@gmail.com> wrote:
> On Wed, May 13, 2015 at 7:49 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> 2015-05-14 Max Filippov <jcmvbkbc@gmail.com>
>> bfd/
>> * elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Treat PLT reference
>> as GOT reference when plt.refcount is not positive.
>
> This is OK, please apply.
Thanks! Checked in.
-- Max
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-14 4:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-14 2:50 [PATCH] xtensa: fix localized symbol refcounting with --gc-sections Max Filippov
2015-05-14 3:58 ` augustine.sterling
2015-05-14 4:10 ` Max Filippov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).