gas: Allow SHF_GNU_RETAIN on all sections
Since SHF_GNU_RETAIN is allowed on all sections, strip SHF_GNU_RETAIN when checking incorrect section attributes. PR gas/27412 * config/obj-elf.c (obj_elf_change_section): Strip SHF_GNU_RETAIN when checking incorrect section attributes. * testsuite/gas/elf/elf.exp: Run section28 and section29. * testsuite/gas/elf/section28.d: New file. * testsuite/gas/elf/section28.s: Likewise. * testsuite/gas/elf/section29.d: Likewise. * testsuite/gas/elf/section29.s: Likewise.
This commit is contained in:
parent
394ae71f02
commit
ca1289b9f3
7 changed files with 66 additions and 6 deletions
|
@ -1,3 +1,14 @@
|
||||||
|
2021-02-16 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
PR gas/27412
|
||||||
|
* config/obj-elf.c (obj_elf_change_section): Strip SHF_GNU_RETAIN
|
||||||
|
when checking incorrect section attributes.
|
||||||
|
* testsuite/gas/elf/elf.exp: Run section28 and section29.
|
||||||
|
* testsuite/gas/elf/section28.d: New file.
|
||||||
|
* testsuite/gas/elf/section28.s: Likewise.
|
||||||
|
* testsuite/gas/elf/section29.d: Likewise.
|
||||||
|
* testsuite/gas/elf/section29.s: Likewise.
|
||||||
|
|
||||||
2021-02-16 Jan Beulich <jbeulich@suse.com>
|
2021-02-16 Jan Beulich <jbeulich@suse.com>
|
||||||
|
|
||||||
* testsuite/gas/i386/sse-check.s,
|
* testsuite/gas/i386/sse-check.s,
|
||||||
|
|
|
@ -667,39 +667,45 @@ obj_elf_change_section (const char *name,
|
||||||
| SHF_MASKPROC))
|
| SHF_MASKPROC))
|
||||||
& ~ssect->attr) != 0)
|
& ~ssect->attr) != 0)
|
||||||
{
|
{
|
||||||
|
/* Strip SHF_GNU_RETAIN. */
|
||||||
|
bfd_vma generic_attr = attr;
|
||||||
|
if (elf_tdata (stdoutput)->has_gnu_osabi)
|
||||||
|
generic_attr &= ~SHF_GNU_RETAIN;
|
||||||
|
|
||||||
/* As a GNU extension, we permit a .note section to be
|
/* As a GNU extension, we permit a .note section to be
|
||||||
allocatable. If the linker sees an allocatable .note
|
allocatable. If the linker sees an allocatable .note
|
||||||
section, it will create a PT_NOTE segment in the output
|
section, it will create a PT_NOTE segment in the output
|
||||||
file. We also allow "x" for .note.GNU-stack. */
|
file. We also allow "x" for .note.GNU-stack. */
|
||||||
if (ssect->type == SHT_NOTE
|
if (ssect->type == SHT_NOTE
|
||||||
&& (attr == SHF_ALLOC || attr == SHF_EXECINSTR))
|
&& (generic_attr == SHF_ALLOC
|
||||||
|
|| generic_attr == SHF_EXECINSTR))
|
||||||
;
|
;
|
||||||
/* Allow different SHF_MERGE and SHF_STRINGS if we have
|
/* Allow different SHF_MERGE and SHF_STRINGS if we have
|
||||||
something like .rodata.str. */
|
something like .rodata.str. */
|
||||||
else if (ssect->suffix_length == -2
|
else if (ssect->suffix_length == -2
|
||||||
&& name[ssect->prefix_length] == '.'
|
&& name[ssect->prefix_length] == '.'
|
||||||
&& (attr
|
&& (generic_attr
|
||||||
& ~ssect->attr
|
& ~ssect->attr
|
||||||
& ~SHF_MERGE
|
& ~SHF_MERGE
|
||||||
& ~SHF_STRINGS) == 0)
|
& ~SHF_STRINGS) == 0)
|
||||||
;
|
;
|
||||||
/* .interp, .strtab and .symtab can have SHF_ALLOC. */
|
/* .interp, .strtab and .symtab can have SHF_ALLOC. */
|
||||||
else if (attr == SHF_ALLOC
|
else if (generic_attr == SHF_ALLOC
|
||||||
&& (strcmp (name, ".interp") == 0
|
&& (strcmp (name, ".interp") == 0
|
||||||
|| strcmp (name, ".strtab") == 0
|
|| strcmp (name, ".strtab") == 0
|
||||||
|| strcmp (name, ".symtab") == 0))
|
|| strcmp (name, ".symtab") == 0))
|
||||||
override = TRUE;
|
override = TRUE;
|
||||||
/* .note.GNU-stack can have SHF_EXECINSTR. */
|
/* .note.GNU-stack can have SHF_EXECINSTR. */
|
||||||
else if (attr == SHF_EXECINSTR
|
else if (generic_attr == SHF_EXECINSTR
|
||||||
&& strcmp (name, ".note.GNU-stack") == 0)
|
&& strcmp (name, ".note.GNU-stack") == 0)
|
||||||
override = TRUE;
|
override = TRUE;
|
||||||
#ifdef TC_ALPHA
|
#ifdef TC_ALPHA
|
||||||
/* A section on Alpha may have SHF_ALPHA_GPREL. */
|
/* A section on Alpha may have SHF_ALPHA_GPREL. */
|
||||||
else if ((attr & ~ssect->attr) == SHF_ALPHA_GPREL)
|
else if ((generic_attr & ~ssect->attr) == SHF_ALPHA_GPREL)
|
||||||
override = TRUE;
|
override = TRUE;
|
||||||
#endif
|
#endif
|
||||||
#ifdef TC_RX
|
#ifdef TC_RX
|
||||||
else if (attr == (SHF_EXECINSTR | SHF_WRITE | SHF_ALLOC)
|
else if (generic_attr == (SHF_EXECINSTR | SHF_WRITE | SHF_ALLOC)
|
||||||
&& (ssect->type == SHT_INIT_ARRAY
|
&& (ssect->type == SHT_INIT_ARRAY
|
||||||
|| ssect->type == SHT_FINI_ARRAY
|
|| ssect->type == SHT_FINI_ARRAY
|
||||||
|| ssect->type == SHT_PREINIT_ARRAY))
|
|| ssect->type == SHT_PREINIT_ARRAY))
|
||||||
|
|
|
@ -273,6 +273,8 @@ if { [is_elf_format] } then {
|
||||||
run_dump_test "section25"
|
run_dump_test "section25"
|
||||||
run_dump_test "section26"
|
run_dump_test "section26"
|
||||||
run_dump_test "section27"
|
run_dump_test "section27"
|
||||||
|
run_dump_test "section28"
|
||||||
|
run_dump_test "section29"
|
||||||
run_dump_test "sh-link-zero"
|
run_dump_test "sh-link-zero"
|
||||||
run_dump_test "dwarf2-1" $dump_opts
|
run_dump_test "dwarf2-1" $dump_opts
|
||||||
run_dump_test "dwarf2-2" $dump_opts
|
run_dump_test "dwarf2-2" $dump_opts
|
||||||
|
|
15
gas/testsuite/gas/elf/section28.d
Normal file
15
gas/testsuite/gas/elf/section28.d
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#readelf: -h -S --wide
|
||||||
|
#name: SHF_GNU_RETAIN sections 28
|
||||||
|
#notarget: ![supports_gnu_osabi]
|
||||||
|
|
||||||
|
#...
|
||||||
|
+OS/ABI: +UNIX - (GNU|FreeBSD)
|
||||||
|
#...
|
||||||
|
\[..\] \.note\.Linux +NOTE +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 +A +0.*
|
||||||
|
#...
|
||||||
|
\[..\] \.note\.Linux +NOTE +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 +AR +0.*
|
||||||
|
#...
|
||||||
|
\[..\] \.note\.foo +NOTE +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 +0 +.*
|
||||||
|
#...
|
||||||
|
\[..\] \.note\.foo +NOTE +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 +R +0 +.*
|
||||||
|
#pass
|
11
gas/testsuite/gas/elf/section28.s
Normal file
11
gas/testsuite/gas/elf/section28.s
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
.section .note.Linux,"a"
|
||||||
|
.word 1
|
||||||
|
|
||||||
|
.section .note.Linux,"aR"
|
||||||
|
.word 1
|
||||||
|
|
||||||
|
.section .note.foo
|
||||||
|
.word 1
|
||||||
|
|
||||||
|
.section .note.foo,"R"
|
||||||
|
.word 1
|
11
gas/testsuite/gas/elf/section29.d
Normal file
11
gas/testsuite/gas/elf/section29.d
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#readelf: -h -S --wide
|
||||||
|
#name: SHF_GNU_RETAIN sections 29
|
||||||
|
#notarget: ![supports_gnu_osabi]
|
||||||
|
|
||||||
|
#...
|
||||||
|
+OS/ABI: +UNIX - (GNU|FreeBSD)
|
||||||
|
#...
|
||||||
|
\[..\] \.rodata\.str1\.1 +PROGBITS +[0-9a-f]+ [0-9a-f]+ 0+4 +01 +AMS +0 +0 +1
|
||||||
|
#...
|
||||||
|
\[..\] \.rodata\.str1\.1 +PROGBITS +[0-9a-f]+ [0-9a-f]+ 0+4 +01 +AMSR +0 +0 +1
|
||||||
|
#pass
|
4
gas/testsuite/gas/elf/section29.s
Normal file
4
gas/testsuite/gas/elf/section29.s
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
.section .rodata.str1.1,"aMS",%progbits,1
|
||||||
|
.asciz "foo"
|
||||||
|
.section .rodata.str1.1,"aMSR",%progbits,1
|
||||||
|
.asciz "bar"
|
Loading…
Add table
Reference in a new issue