This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [2.26] [PATCH] PR ld/19319: Regression: ld.bfd: 2.25.90.20151125 assertion fail ../../bfd/elf32-i386.c:5297
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Tristan Gingold <gingold at adacore dot com>, Binutils <binutils at sourceware dot org>
- Date: Sat, 5 Dec 2015 08:32:49 -0800
- Subject: Re: [2.26] [PATCH] PR ld/19319: Regression: ld.bfd: 2.25.90.20151125 assertion fail ../../bfd/elf32-i386.c:5297
- Authentication-results: sourceware.org; auth=none
- References: <CAMe9rOp-xXm0o=P0P4d_4veDApw7YL9yd1bt6HJWpghhww9Upg at mail dot gmail dot com>
I am checking it into 2.26 branch.
On Thu, Dec 3, 2015 at 5:57 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> OK for binutils-2_26-branch?
>
>
> H.J.
> ---------- Forwarded message ----------
> From: H.J. Lu <hongjiu.lu@intel.com>
> Date: Tue, Dec 1, 2015 at 2:59 PM
> Subject: [PATCH] PR ld/19319: Regression: ld.bfd: 2.25.90.20151125
> assertion fail ../../bfd/elf32-i386.c:5297
> To: binutils@sourceware.org
>
>
> Symbol defined by a linker assignment may have type bfd_link_hash_new
> or bfd_link_hash_undefined. And h->def_regular is always set.
> elf_i386_convert_load and elf_x86_64_convert_load should check
> h->def_regular as well as bfd_link_hash_undefined and bfd_link_hash_new
> to see if a symbol is defined by a linker script.
>
> Checked into master. This is a regression on 2.26 branch. OK for
> binutils-2_26-branch?
>
>
> H.J.
> ---
> bfd/
>
> PR ld/19319
> * elf32-i386.c (elf_i386_convert_load): Check h->def_regular
> instead of bfd_link_hash_new.
> * elf64-x86-64.c (elf_x86_64_convert_load): Likewise. Skip
> relocation overflow for bfd_link_hash_undefined and
> bfd_link_hash_new if h->def_regular is set.
>
> ld/testsuite/
>
> PR ld/19319
> * ld-i386/i386.exp: Run pr19319 test.
> * ld-x86-64/x86-64.exp: Likewise.
> * ld-i386/pr19319.dd: New file.
> * ld-i386/pr19319a.S: Likewise.
> * ld-i386/pr19319b.S: Likewise.
> * ld-x86-64/pr19319.dd: Likewise.
> * ld-x86-64/pr19319a.S: Likewise.
> * ld-x86-64/pr19319b.S: Likewise.
> ---
> bfd/ChangeLog | 9 +++++++++
> bfd/elf32-i386.c | 10 +++++-----
> bfd/elf64-x86-64.c | 19 +++++++++++--------
> ld/testsuite/ChangeLog | 12 ++++++++++++
> ld/testsuite/ld-i386/i386.exp | 16 ++++++++++++++++
> ld/testsuite/ld-i386/pr19319.dd | 4 ++++
> ld/testsuite/ld-i386/pr19319a.S | 11 +++++++++++
> ld/testsuite/ld-i386/pr19319b.S | 11 +++++++++++
> ld/testsuite/ld-x86-64/pr19319.dd | 4 ++++
> ld/testsuite/ld-x86-64/pr19319a.S | 11 +++++++++++
> ld/testsuite/ld-x86-64/pr19319b.S | 11 +++++++++++
> ld/testsuite/ld-x86-64/x86-64.exp | 16 ++++++++++++++++
> 12 files changed, 121 insertions(+), 13 deletions(-)
> create mode 100644 ld/testsuite/ld-i386/pr19319.dd
> create mode 100644 ld/testsuite/ld-i386/pr19319a.S
> create mode 100644 ld/testsuite/ld-i386/pr19319b.S
> create mode 100644 ld/testsuite/ld-x86-64/pr19319.dd
> create mode 100644 ld/testsuite/ld-x86-64/pr19319a.S
> create mode 100644 ld/testsuite/ld-x86-64/pr19319b.S
>
> diff --git a/bfd/ChangeLog b/bfd/ChangeLog
> index ca4f130..544ed88 100644
> --- a/bfd/ChangeLog
> +++ b/bfd/ChangeLog
> @@ -1,3 +1,12 @@
> +2015-12-01 H.J. Lu <hongjiu.lu@intel.com>
> +
> + PR ld/19319
> + * elf32-i386.c (elf_i386_convert_load): Check h->def_regular
> + instead of bfd_link_hash_new.
> + * elf64-x86-64.c (elf_x86_64_convert_load): Likewise. Skip
> + relocation overflow for bfd_link_hash_undefined and
> + bfd_link_hash_new if h->def_regular is set.
> +
> 2015-12-01 Alan Modra <amodra@gmail.com>
>
> * aoutx.h (adjust_sizes_and_vmas): Remove unused text_size and
> diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
> index 1df7244..ae3187d 100644
> --- a/bfd/elf32-i386.c
> +++ b/bfd/elf32-i386.c
> @@ -2976,11 +2976,11 @@ convert_branch:
> if (h == htab->elf.hdynamic)
> continue;
>
> - /* bfd_link_hash_new is set by an assignment in a linker
> - script in bfd_elf_record_link_assignment. */
> - if ((h->root.type == bfd_link_hash_defined
> - || h->root.type == bfd_link_hash_defweak
> - || h->root.type == bfd_link_hash_new)
> + /* def_regular is set by an assignment in a linker script in
> + bfd_elf_record_link_assignment. */
> + if ((h->def_regular
> + || h->root.type == bfd_link_hash_defined
> + || h->root.type == bfd_link_hash_defweak)
> && SYMBOL_REFERENCES_LOCAL (link_info, h))
> {
> convert_load:
> diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
> index 8e00362..63957bb 100644
> --- a/bfd/elf64-x86-64.c
> +++ b/bfd/elf64-x86-64.c
> @@ -3127,18 +3127,21 @@ elf_x86_64_convert_load (bfd *abfd, asection *sec,
> /* STT_GNU_IFUNC must keep GOTPCREL relocations. We also
> avoid optimizing GOTPCREL relocations againt _DYNAMIC
> since ld.so may use its link-time address. */
> - if ((h->root.type == bfd_link_hash_defined
> - || h->root.type == bfd_link_hash_defweak
> - || h->root.type == bfd_link_hash_new)
> + if ((h->def_regular
> + || h->root.type == bfd_link_hash_defined
> + || h->root.type == bfd_link_hash_defweak)
> && h->type != STT_GNU_IFUNC
> && h != htab->elf.hdynamic
> && SYMBOL_REFERENCES_LOCAL (link_info, h))
> {
> - /* bfd_link_hash_new is set by an assignment in a linker
> - script in bfd_elf_record_link_assignment. FIXME: If
> - we ever get a linker error due relocation overflow, we
> - will skip this optimization. */
> - if (h->root.type == bfd_link_hash_new)
> + /* bfd_link_hash_new or bfd_link_hash_undefined is
> + set by an assignment in a linker script in
> + bfd_elf_record_link_assignment. FIXME: If we
> + ever get a linker error due relocation overflow,
> + we will skip this optimization. */
> + if (h->def_regular
> + && (h->root.type == bfd_link_hash_new
> + || h->root.type == bfd_link_hash_undefined))
> goto convert;
> tsec = h->root.u.def.section;
> toff = h->root.u.def.value;
> diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
> index 739f09f..d7ef3c4 100644
> --- a/ld/testsuite/ChangeLog
> +++ b/ld/testsuite/ChangeLog
> @@ -1,3 +1,15 @@
> +2015-12-01 H.J. Lu <hongjiu.lu@intel.com>
> +
> + PR ld/19319
> + * ld-i386/i386.exp: Run pr19319 test.
> + * ld-x86-64/x86-64.exp: Likewise.
> + * ld-i386/pr19319.dd: New file.
> + * ld-i386/pr19319a.S: Likewise.
> + * ld-i386/pr19319b.S: Likewise.
> + * ld-x86-64/pr19319.dd: Likewise.
> + * ld-x86-64/pr19319a.S: Likewise.
> + * ld-x86-64/pr19319b.S: Likewise.
> +
> 2015-11-11 Alan Modra <amodra@gmail.com>
> Peter Bergner <bergner@vnet.ibm.com>
>
> diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
> index 84a63e8..a6601ed 100644
> --- a/ld/testsuite/ld-i386/i386.exp
> +++ b/ld/testsuite/ld-i386/i386.exp
> @@ -537,6 +537,22 @@ if { [isnative]
> {{objdump {-dw} got1.dd}} \
> "got1" \
> ] \
> + [list \
> + "Build pr19319.so" \
> + "-shared" \
> + "" \
> + { pr19319a.S } \
> + "" \
> + "pr19319.so" \
> + ] \
> + [list \
> + "Build pr19319" \
> + "-pie -nostdlib -nostartfiles tmpdir/pr19319.so" \
> + "" \
> + { pr19319b.S } \
> + {{objdump {-dw} pr19319.dd}} \
> + "pr19319" \
> + ] \
> ]
>
> run_ld_link_exec_tests [] [list \
> diff --git a/ld/testsuite/ld-i386/pr19319.dd b/ld/testsuite/ld-i386/pr19319.dd
> new file mode 100644
> index 0000000..f2593da
> --- /dev/null
> +++ b/ld/testsuite/ld-i386/pr19319.dd
> @@ -0,0 +1,4 @@
> +#...
> +[a-f0-9]+ <_start>:
> +[ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea
> 0x[a-f0-9]+\(%ecx\),%eax
> +#pass
> diff --git a/ld/testsuite/ld-i386/pr19319a.S b/ld/testsuite/ld-i386/pr19319a.S
> new file mode 100644
> index 0000000..04082be
> --- /dev/null
> +++ b/ld/testsuite/ld-i386/pr19319a.S
> @@ -0,0 +1,11 @@
> + .text
> + .globl foo
> + .type foo, @function
> +foo:
> + movl __start_my_section@GOT(%ecx), %eax
> + ret
> + .size foo, .-foo
> + .section my_section,"aw",@progbits
> + .align 8
> + .long 4660
> + .long 22136
> diff --git a/ld/testsuite/ld-i386/pr19319b.S b/ld/testsuite/ld-i386/pr19319b.S
> new file mode 100644
> index 0000000..98294f6
> --- /dev/null
> +++ b/ld/testsuite/ld-i386/pr19319b.S
> @@ -0,0 +1,11 @@
> + .text
> + .globl _start
> + .type _start, @function
> +_start:
> + movl __start_my_section@GOT(%ecx), %eax
> + ret
> + .size _start, .-_start
> + .section my_section,"aw",@progbits
> + .align 8
> + .long 4660
> + .long 22136
> diff --git a/ld/testsuite/ld-x86-64/pr19319.dd
> b/ld/testsuite/ld-x86-64/pr19319.dd
> new file mode 100644
> index 0000000..9d6ffd9
> --- /dev/null
> +++ b/ld/testsuite/ld-x86-64/pr19319.dd
> @@ -0,0 +1,4 @@
> +#...
> +[a-f0-9]+ <_start>:
> +[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea
> 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__start_my_section>
> +#pass
> diff --git a/ld/testsuite/ld-x86-64/pr19319a.S
> b/ld/testsuite/ld-x86-64/pr19319a.S
> new file mode 100644
> index 0000000..438d7a5
> --- /dev/null
> +++ b/ld/testsuite/ld-x86-64/pr19319a.S
> @@ -0,0 +1,11 @@
> + .text
> + .globl foo
> + .type foo, @function
> +foo:
> + movq __start_my_section@GOTPCREL(%rip), %rax
> + ret
> + .size foo, .-foo
> + .section my_section,"aw",@progbits
> + .align 8
> + .long 4660
> + .long 22136
> diff --git a/ld/testsuite/ld-x86-64/pr19319b.S
> b/ld/testsuite/ld-x86-64/pr19319b.S
> new file mode 100644
> index 0000000..c9285c0
> --- /dev/null
> +++ b/ld/testsuite/ld-x86-64/pr19319b.S
> @@ -0,0 +1,11 @@
> + .text
> + .globl _start
> + .type _start, @function
> +_start:
> + movq __start_my_section@GOTPCREL(%rip), %rax
> + ret
> + .size _start, .-_start
> + .section my_section,"aw",@progbits
> + .align 8
> + .long 4660
> + .long 22136
> diff --git a/ld/testsuite/ld-x86-64/x86-64.exp
> b/ld/testsuite/ld-x86-64/x86-64.exp
> index 63d7211..f0f47eb 100644
> --- a/ld/testsuite/ld-x86-64/x86-64.exp
> +++ b/ld/testsuite/ld-x86-64/x86-64.exp
> @@ -546,6 +546,22 @@ if { [isnative] && [which $CC] != 0 } {
> {{objdump {-dw} gotpcrel1.dd}} \
> "gotpcrel1" \
> ] \
> + [list \
> + "Build pr19319.so" \
> + "-shared" \
> + "" \
> + { pr19319a.S } \
> + "" \
> + "pr19319.so" \
> + ] \
> + [list \
> + "Build pr19319" \
> + "-pie -nostdlib -nostartfiles tmpdir/pr19319.so" \
> + "" \
> + { pr19319b.S } \
> + {{objdump {-dw} pr19319.dd}} \
> + "pr19319" \
> + ] \
> ]
>
> run_ld_link_exec_tests [] [list \
> --
> 2.5.0
>
>
>
> --
> H.J.
--
H.J.