diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2017-11-17 05:06:13 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2017-11-17 05:06:13 -0800 |
commit | 9a47c68169e0ddc01463c2d2ea2420a80f1d12b9 (patch) | |
tree | f13dad7ffc45935e3c2b564e74c7ed0e43134cbb | |
parent | 2c244f9b0935e577d7c20bb5706e27438e48227f (diff) | |
download | binutils-gdb-users/hjl/pr22450.tar.gz |
ld: Check if GNU property note section existsusers/hjl/pr22450
GNU property must be placed in .note.gnu.property section. It is
an error if GNU property is placed in other note sections.
bfd/
PR ld/22450
* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Call
linker callback if GNU property note section doesn't exist.
ld/
PR ld/22450
* testsuite/ld-elf/elf.exp: Run PR ld/22450 test.
* testsuite/ld-elf/pr22450.S: New file.
* testsuite/ld-elf/pr22450.err: Likewise.
-rw-r--r-- | bfd/elf-properties.c | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/elf.exp | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr22450.S | 23 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr22450.err | 2 |
4 files changed, 40 insertions, 0 deletions
diff --git a/bfd/elf-properties.c b/bfd/elf-properties.c index bfb106edc92..7d58f0cc140 100644 --- a/bfd/elf-properties.c +++ b/bfd/elf-properties.c @@ -394,6 +394,10 @@ _bfd_elf_link_setup_gnu_properties (struct bfd_link_info *info) sec = bfd_get_section_by_name (first_pbfd, NOTE_GNU_PROPERTY_SECTION_NAME); + if (sec == NULL) + info->callbacks->einfo (_("%P%F: failed to find GNU property section: %s\n"), + NOTE_GNU_PROPERTY_SECTION_NAME); + /* Update stack size in .note.gnu.property with -z stack-size=N if N > 0. */ if (info->stacksize > 0) diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp index acdad8db22a..4ec7a3e1516 100644 --- a/ld/testsuite/ld-elf/elf.exp +++ b/ld/testsuite/ld-elf/elf.exp @@ -352,6 +352,17 @@ if { [istarget *-*-linux*] ] } +run_cc_link_tests [list \ + [list \ + "PR ld/22450" \ + "-Wl,-r -nostdlib -nostartfiles" \ + "" \ + { pr22450.S } \ + {{error_output "pr22450.err"}} \ + "pr22450" \ + ] \ +] + # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static> # Be cautious to not XFAIL for *-*-linux-gnu*, *-*-kfreebsd-gnu*, etc. switch -regexp $target_triplet { diff --git a/ld/testsuite/ld-elf/pr22450.S b/ld/testsuite/ld-elf/pr22450.S new file mode 100644 index 00000000000..b2593f25f0a --- /dev/null +++ b/ld/testsuite/ld-elf/pr22450.S @@ -0,0 +1,23 @@ +#ifdef __LP64__ +# define ALIGN 3 +#else +# define ALIGN 2 +#endif + .section ".note.gnu", "a" + .p2align ALIGN + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align ALIGN + /* GNU_PROPERTY_STACK_SIZE */ + .long 1 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .dc.a 0x800000 /* Stack size. */ +5: + .p2align ALIGN +3: diff --git a/ld/testsuite/ld-elf/pr22450.err b/ld/testsuite/ld-elf/pr22450.err new file mode 100644 index 00000000000..387e1a38534 --- /dev/null +++ b/ld/testsuite/ld-elf/pr22450.err @@ -0,0 +1,2 @@ +.*: failed to find GNU property section: .note.gnu.property +#... |