* [PATCH] Fix segmentation fault in bfd/elf32-hppa.c
@ 2023-12-12 17:21 John David Anglin
2023-12-13 0:01 ` Alan Modra
0 siblings, 1 reply; 3+ messages in thread
From: John David Anglin @ 2023-12-12 17:21 UTC (permalink / raw)
To: Binutils; +Cc: Alan Modra
[-- Attachment #1: Type: text/plain, Size: 898 bytes --]
Tested on hppa-unknown-linux-gnu with no regressions.
Okay?
Dave
---
Fix segmentation fault in bfd/elf32-hppa.c
2023-12-12 John David Anglin <danglin@gcc.gnu.org>
PR ld/31148
bfd/ChangeLog:
* elf32-hppa.c (elf32_hppa_finish_dynamic_symbol): Don't output
relative reloc if eh->root.type is bfd_link_hash_undefined.
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 44129c80138..131f6806aa7 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -4216,7 +4216,7 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
file, we just want to emit a RELATIVE reloc. The entry
in the global offset table will already have been
initialized in the relocate_section function. */
- if (!is_dyn)
+ if (!is_dyn && eh->root.type != bfd_link_hash_undefined)
{
rela.r_info = ELF32_R_INFO (0, R_PARISC_DIR32);
rela.r_addend = (eh->root.u.def.value
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix segmentation fault in bfd/elf32-hppa.c
2023-12-12 17:21 [PATCH] Fix segmentation fault in bfd/elf32-hppa.c John David Anglin
@ 2023-12-13 0:01 ` Alan Modra
2023-12-15 21:13 ` John David Anglin
0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2023-12-13 0:01 UTC (permalink / raw)
To: John David Anglin; +Cc: Binutils
On Tue, Dec 12, 2023 at 05:21:28PM +0000, John David Anglin wrote:
> diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
> index 44129c80138..131f6806aa7 100644
> --- a/bfd/elf32-hppa.c
> +++ b/bfd/elf32-hppa.c
> @@ -4216,7 +4216,7 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
> file, we just want to emit a RELATIVE reloc. The entry
> in the global offset table will already have been
> initialized in the relocate_section function. */
> - if (!is_dyn)
> + if (!is_dyn && eh->root.type != bfd_link_hash_undefined)
> {
> rela.r_info = ELF32_R_INFO (0, R_PARISC_DIR32);
> rela.r_addend = (eh->root.u.def.value
Since the code uses u.def here, it is better IMO to test explicitly
for either bfd_link_hash_defined or bfd_link_hash_defweak. I'm left
wondering whether there isn't some case where we get here with an
undefweak (or common, or new, or..) symbol.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix segmentation fault in bfd/elf32-hppa.c
2023-12-13 0:01 ` Alan Modra
@ 2023-12-15 21:13 ` John David Anglin
0 siblings, 0 replies; 3+ messages in thread
From: John David Anglin @ 2023-12-15 21:13 UTC (permalink / raw)
To: Alan Modra, John David Anglin; +Cc: Binutils
After retesting, I committed the following change. Hopefully, there aren't
other types that need handling.
Dave
---
Fix segmentation fault in bfd/elf32-hppa.c
2023-12-15 John David Anglin <danglin@gcc.gnu.org>
PR ld/31148
bfd/ChangeLog:
* elf32-hppa.c (elf32_hppa_finish_dynamic_symbol): Output
relative reloc only when eh->root.type is bfd_link_hash_defined
or bfd_link_hash_defweak.
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 44129c80138..d64ca7528a0 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -4216,7 +4216,9 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
file, we just want to emit a RELATIVE reloc. The entry
in the global offset table will already have been
initialized in the relocate_section function. */
- if (!is_dyn)
+ if (!is_dyn
+ && (eh->root.type == bfd_link_hash_defined
+ || eh->root.type == bfd_link_hash_defweak))
{
rela.r_info = ELF32_R_INFO (0, R_PARISC_DIR32);
rela.r_addend = (eh->root.u.def.value
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-15 21:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-12 17:21 [PATCH] Fix segmentation fault in bfd/elf32-hppa.c John David Anglin
2023-12-13 0:01 ` Alan Modra
2023-12-15 21:13 ` John David Anglin
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).