diff options
author | Hans-Peter Nilsson <hp@axis.com> | 2020-09-15 03:59:06 +0200 |
---|---|---|
committer | Hans-Peter Nilsson <hp@bitrange.com> | 2020-09-15 03:59:06 +0200 |
commit | ef6b667ead5c32c7d26faffff58f1f86f70a662b (patch) | |
tree | 41c6cdfa5f75cf0a0fae3f2a2d189ae5589da1c6 | |
parent | 702759286fde3840d8df5debe10fd752b3bd0126 (diff) | |
download | gdb-ef6b667ead5c32c7d26faffff58f1f86f70a662b.zip gdb-ef6b667ead5c32c7d26faffff58f1f86f70a662b.tar.gz gdb-ef6b667ead5c32c7d26faffff58f1f86f70a662b.tar.bz2 |
CRIS: fix PR ld/26589, a missing NULL check in fix for PR ld/22269
Not sure why there wasn't a NULL check in the ld/22269 patch
(e01c16a8) at the time, as there was one for the corresponding patch
to elf32-m68k.c (5056ba1d).
Incidentally, I had missed that in 2017, as a prerequisite for the
ld/22269 series, the check_relocs function finally were made "safe"!
(I.e. the number of references and symbol types are final, garbage
collection done, so port-specific accounting can be made sanely.)
Committed.
bfd:
PR ld/26589
* elf32-cris.c (cris_elf_check_relocs): Add missing NULL check
on argument before calling UNDEFWEAK_NO_DYNAMIC_RELOC.
ld:
PR ld/26589
* testsuite/ld-elf/pr26589.d, testsuite/ld-elf/locref3.s: New test.
(cherry picked from commit 4a8f181d196f85ca153fe51ca6bb40942e0e1ed7)
-rw-r--r-- | bfd/ChangeLog | 7 | ||||
-rw-r--r-- | bfd/elf32-cris.c | 2 | ||||
-rw-r--r-- | ld/ChangeLog | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-cris/locref3.s | 14 | ||||
-rw-r--r-- | ld/testsuite/ld-cris/pr26589.d | 16 |
5 files changed, 44 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5d0c57d..b1f6007 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2020-09-15 Hans-Peter Nilsson <hp@axis.com> + + Backport from mainline: + PR ld/26589 + * elf32-cris.c (cris_elf_check_relocs): Add missing NULL check + on argument before calling UNDEFWEAK_NO_DYNAMIC_RELOC. + 2020-09-10 Alan Modra <amodra@gmail.com> Apply from master diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 4360b54..2c0db65 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -3358,7 +3358,7 @@ cris_elf_check_relocs (bfd *abfd, /* No need to do anything if we're not creating a shared object. */ if (! bfd_link_pic (info) - || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)) + || (h != NULL && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))) break; /* We may need to create a reloc section in the dynobj and made room diff --git a/ld/ChangeLog b/ld/ChangeLog index d02d150..d927be5 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2020-09-15 Hans-Peter Nilsson <hp@axis.com> + + Backport from mainline: + PR ld/26589 + * testsuite/ld-elf/pr26589.d, testsuite/ld-elf/locref3.s: New test. + 2020-09-10 Alan Modra <amodra@gmail.com> Apply from master diff --git a/ld/testsuite/ld-cris/locref3.s b/ld/testsuite/ld-cris/locref3.s new file mode 100644 index 0000000..7991097 --- /dev/null +++ b/ld/testsuite/ld-cris/locref3.s @@ -0,0 +1,14 @@ +; Test-case primarily from PR26589, which could have been locref3.d. +; A local (like "static") function, with all ELF decorations. +.text + .type alocalfunc,@function + .p2align 1 +alocalfunc: + nop +.Lfe1: + .size alocalfunc,.Lfe1-alocalfunc + +; Random absolute reference to the address of alocalfunc, requiring a +; runtime relocation in code that needs to be PIC/PIE. + .data + .dword alocalfunc diff --git a/ld/testsuite/ld-cris/pr26589.d b/ld/testsuite/ld-cris/pr26589.d new file mode 100644 index 0000000..aee3143 --- /dev/null +++ b/ld/testsuite/ld-cris/pr26589.d @@ -0,0 +1,16 @@ +#source: dso-1.s +#source: locref3.s +#as: --pic --no-underscore --em=criself +#ld: --shared -m crislinux +#readelf: --dyn-syms -r + +# Besides typical DSO stuff (libdso-1.d), we here have a data section +# with an absolute reloc to a local symbol. For the original +# test-case, this happened for a destructor (.dtors). + +Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 1 entry: + Offset[ ]+Info[ ]+Type[ ]+Sym\.Value Sym\. Name \+ Addend +[a-f0-9]+[ ]+0+c R_CRIS_RELATIVE[ ]+ [a-f0-9]+ + +Symbol table '\.dynsym' contains 3 entries: +#pass |