This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH v2] ARM: Replace catch of noread sections by section name by a section attribute letter.
- From: mickael guene <mickael dot guene at st dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Cc: <Andre dot SimoesDiasVieira at arm dot com>
- Date: Tue, 19 Jan 2016 10:53:05 +0100
- Subject: [PATCH v2] ARM: Replace catch of noread sections by section name by a section attribute letter.
- Authentication-results: sourceware.org; auth=none
Hi all,
This is a proposal for a patch that replaces the catch of noread
sections by section name by a section attribute letter.
I have taken changes from Terry Guo's patch[1] for documentation and
for section-execute-only.s test.
No regressions have been observed for arm-linux-gnueabi,
arm-linux-gnueabihf, arm-none-eabi, arm-none-nacl,
armeb-linux-gnueabihf, arm-netbsdelf and arm-vxworks targets
on 64-bit Linux host.
In this v2 we replace, in readelf section output, display
of processor specific letter 'p' with letter 'y' for section
with SHF_ARM_NOREAD section flag.
[1]: https://sourceware.org/ml/binutils/2014-04/msg00181.html
Changelogs:
bfd/ChangeLog:
2016-01-12 Mickael Guene <mickael.guene@st.com>
* elf32-arm.c ((elf32_arm_special_sections): Remove catch of noread
section using '.text.noread' pattern.
gas/ChangeLog:
2016-01-12 Mickael Guene <mickael.guene@st.com>
* config/obj-elf.c (obj_elf_change_section) : Allow arm section with
SHF_ARM_NOREAD section flag.
* config/tc-arm.h (md_elf_section_letter) : Implement this hook to
handle letter 'y'.
(arm_elf_section_letter) : Declare it.
* config/tc-arm.c (arm_elf_section_letter): Handle letter 'y' to set
SHF_ARM_NOREAD section flag.
* doc/c-arm.texi (ARM section attribute 'y'): Document it.
gas/testsuite/ChangeLog:
2016-01-12 Terry Guo <terry.guo@arm.com>
* gas/arm/section-execute-only.s: New test case.
* gas/arm/section-execute-only.d: Expected output.
ld/testsuite/ChangeLog:
2016-01-12 Mickael Guene <mickael.guene@st.com>
* ld-arm/thumb1-noread-not-present-mixing-two-section.s: Add 'y'
attribute usage.
* ld-arm/thumb1-noread-present-one-section.s: Likewise.
* ld-arm/thumb1-noread-present-two-section.s: Likewise.
* ld-arm/thumb1-input-section-flag-match.s: Likewise.
binutils/ChangeLog:
2016-01-19 Mickael Guene <mickael.guene@st.com>
* readelf.c (get_elf_section_flags): Display y letter for section
with SHF_ARM_NOREAD section flag in readelf section output.
(process_section_headers): Add y letter in readelf section output
key mapping for ARM architecture.
>From 9b14f3a28752d70bc6e7ea1dd165dd69f41ffca8 Mon Sep 17 00:00:00 2001
From: Mickael Guene <mickael.guene@st.com>
Date: Tue, 12 Jan 2016 08:28:59 +0100
Subject: [PATCH] Replace NOREAD setting using section name with section
attribute
---
bfd/elf32-arm.c | 12 ---------
binutils/readelf.c | 8 ++++++
gas/config/obj-elf.c | 9 +++++++
gas/config/tc-arm.c | 10 ++++++++
gas/config/tc-arm.h | 3 +++
gas/doc/c-arm.texi | 11 ++++++++
gas/testsuite/gas/arm/section-execute-only.d | 27 +++++++++++++++++++
gas/testsuite/gas/arm/section-execute-only.s | 30 ++++++++++++++++++++++
.../ld-arm/thumb1-input-section-flag-match.s | 2 +-
.../thumb1-noread-not-present-mixing-two-section.s | 2 +-
.../ld-arm/thumb1-noread-present-one-section.s | 2 +-
.../ld-arm/thumb1-noread-present-two-section.s | 4 +--
12 files changed, 103 insertions(+), 17 deletions(-)
create mode 100644 gas/testsuite/gas/arm/section-execute-only.d
create mode 100644 gas/testsuite/gas/arm/section-execute-only.s
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 1c52526..39b6153 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -17839,16 +17839,6 @@ elf32_arm_get_synthetic_symtab (bfd *abfd,
return n;
}
-static const struct bfd_elf_special_section
-elf32_arm_special_sections[] =
-{
-/* Catch sections with .text.noread prefix and apply allocate, execute and
- noread section attributes. */
- { STRING_COMMA_LEN (".text.noread"), -2, SHT_PROGBITS,
- SHF_ALLOC + SHF_EXECINSTR + SHF_ARM_NOREAD },
- { NULL, 0, 0, 0, 0 }
-};
-
static bfd_boolean
elf32_arm_section_flags (flagword *flags, const Elf_Internal_Shdr * hdr)
{
@@ -17953,8 +17943,6 @@ elf32_arm_count_additional_relocs (asection *sec)
#define elf_backend_obj_attrs_order elf32_arm_obj_attrs_order
#define elf_backend_obj_attrs_handle_unknown elf32_arm_obj_attrs_handle_unknown
-#undef elf_backend_special_sections
-#define elf_backend_special_sections elf32_arm_special_sections
#undef elf_backend_section_flags
#define elf_backend_section_flags elf32_arm_section_flags
#undef elf_backend_lookup_section_flags_hook
diff --git a/binutils/readelf.c b/binutils/readelf.c
index f74ef7b..af77b11 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -5410,6 +5410,9 @@ get_elf_section_flags (bfd_vma sh_flags)
|| elf_header.e_machine == EM_K1OM)
&& flag == SHF_X86_64_LARGE)
*p = 'l';
+ else if (elf_header.e_machine == EM_ARM
+ && flag == SHF_ARM_NOREAD)
+ *p = 'y';
else if (flag & SHF_MASKOS)
{
*p = 'o';
@@ -5987,6 +5990,11 @@ process_section_headers (FILE * file)
W (write), A (alloc), X (execute), M (merge), S (strings), l (large)\n\
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)\n\
O (extra OS processing required) o (OS specific), p (processor specific)\n"));
+ else if (elf_header.e_machine == EM_ARM)
+ printf (_("Key to Flags:\n\
+ W (write), A (alloc), X (execute), M (merge), S (strings), y (noread)\n\
+ I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)\n\
+ O (extra OS processing required) o (OS specific), p (processor specific)\n"));
else
printf (_("Key to Flags:\n\
W (write), A (alloc), X (execute), M (merge), S (strings)\n\
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index f4726ff..6d6d5f3 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -64,6 +64,10 @@
#include "elf/nios2.h"
#endif
+#ifdef TC_ARM
+#include "elf/arm.h"
+#endif
+
static void obj_elf_line (int);
static void obj_elf_size (int);
static void obj_elf_type (int);
@@ -674,6 +678,11 @@ obj_elf_change_section (const char *name,
/* RX init/fini arrays can and should have the "awx" attributes set. */
;
#endif
+#ifdef TC_ARM
+ else if (attr == (SHF_EXECINSTR | SHF_ARM_NOREAD | SHF_ALLOC))
+ /* ARM can have code section with SHF_ARM_NOREAD attribute. */
+ ;
+#endif
else
{
if (group_name == NULL)
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 046abe5..aa05170 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -24090,6 +24090,16 @@ arm_fix_adjustable (fixS * fixP)
}
#endif /* defined (OBJ_ELF) || defined (OBJ_COFF) */
+bfd_vma
+arm_elf_section_letter (int letter, char **ptrmsg)
+{
+ if (letter == 'y')
+ return SHF_ARM_NOREAD;
+
+ *ptrmsg = _("unrecognized .section attribute: want a,e,w,x,y,M,S,G,T");
+ return -1;
+}
+
#ifdef OBJ_ELF
const char *
diff --git a/gas/config/tc-arm.h b/gas/config/tc-arm.h
index 319b2c2..7b3e087 100644
--- a/gas/config/tc-arm.h
+++ b/gas/config/tc-arm.h
@@ -113,6 +113,9 @@ extern bfd_boolean tc_start_label_without_colon (void);
/* We also need to mark assembler created symbols: */
#define tc_frob_fake_label(S) arm_frob_label (S)
+#define md_elf_section_letter arm_elf_section_letter
+extern bfd_vma arm_elf_section_letter (int, char **);
+
#ifdef OBJ_ELF
#define md_end arm_md_end
extern void arm_md_end (void);
diff --git a/gas/doc/c-arm.texi b/gas/doc/c-arm.texi
index 4ee6a21..9449ab7 100644
--- a/gas/doc/c-arm.texi
+++ b/gas/doc/c-arm.texi
@@ -23,6 +23,7 @@
* ARM Opcodes:: Opcodes
* ARM Mapping Symbols:: Mapping Symbols
* ARM Unwinding Tutorial:: Unwinding
+* ARM Section Attribute:: Section Attribute
@end menu
@node ARM Options
@@ -1237,3 +1238,13 @@ code that calls functions which may throw exceptions. If you need to
know more about the object-file format used to represent unwind
information, you may consult the @cite{Exception Handling ABI for the
ARM Architecture} available from @uref{http://infocenter.arm.com}.
+
+@node ARM Section Attribute
+@section Section Attribute
+
+@cindex ARM section attribute
+@table @code
+@item y
+text section with NOREAD attribute for target that supports this feature,
+otherwise such section will be treated as normal text section.
+@end table
diff --git a/gas/testsuite/gas/arm/section-execute-only.d b/gas/testsuite/gas/arm/section-execute-only.d
new file mode 100644
index 0000000..d45a132
--- /dev/null
+++ b/gas/testsuite/gas/arm/section-execute-only.d
@@ -0,0 +1,27 @@
+# name: test executable-only section attribute
+# as:
+# readelf: -t
+# This test is only valid on EABI based ports.
+# target: *-*-*eabi* *-*-nacl*
+There are 10 section headers, starting at offset 0x16c:
+
+Section Headers:
+ \[Nr\] Name
+ Type Addr Off Size ES Lk Inf Al
+ Flags
+ \[ 0\]
+ NULL 00000000 000000 000000 00 0 0 0
+ \[00000000\]:
+ \[ 1\] .text
+ PROGBITS 00000000 000034 000000 00 0 0 2
+ \[00000006\]: ALLOC, EXEC
+ \[ 2\] .data
+ PROGBITS 00000000 000034 000000 00 0 0 1
+ \[00000003\]: WRITE, ALLOC
+ \[ 3\] .bss
+ NOBITS 00000000 000034 000000 00 0 0 1
+ \[00000003\]: WRITE, ALLOC
+ \[ 4\] .text.foo
+ PROGBITS 00000000 000034 000010 00 0 0 4
+ \[20000006\]: ALLOC, EXEC, ARM_NOREAD
+#pass
diff --git a/gas/testsuite/gas/arm/section-execute-only.s b/gas/testsuite/gas/arm/section-execute-only.s
new file mode 100644
index 0000000..9d5ffc6
--- /dev/null
+++ b/gas/testsuite/gas/arm/section-execute-only.s
@@ -0,0 +1,30 @@
+ .syntax unified
+ .cpu cortex-m3
+ .fpu softvfp
+ .eabi_attribute 20, 1
+ .eabi_attribute 21, 1
+ .eabi_attribute 23, 3
+ .eabi_attribute 24, 1
+ .eabi_attribute 25, 1
+ .eabi_attribute 26, 1
+ .eabi_attribute 30, 2
+ .eabi_attribute 34, 1
+ .eabi_attribute 18, 4
+ .thumb
+ .section .text.foo,"axy",%progbits
+ .align 2
+ .global foo
+ .thumb
+ .thumb_func
+ .type foo, %function
+foo:
+ @ args = 0, pretend = 0, frame = 0
+ @ frame_needed = 0, uses_anonymous_args = 0
+ @ link register save eliminated.
+ movs r0, #1
+ movs r1, #1
+ movw r2, #257
+ movs r3, #1
+ b madd
+ .size foo, .-foo
+
diff --git a/ld/testsuite/ld-arm/thumb1-input-section-flag-match.s b/ld/testsuite/ld-arm/thumb1-input-section-flag-match.s
index ac7c89f..6f1ad62 100644
--- a/ld/testsuite/ld-arm/thumb1-input-section-flag-match.s
+++ b/ld/testsuite/ld-arm/thumb1-input-section-flag-match.s
@@ -1,5 +1,5 @@
.text
- .section .text.noread
+ .section .text.fetchonly,"axy",%progbits
.arch armv6s-m
.syntax unified
.global _start
diff --git a/ld/testsuite/ld-arm/thumb1-noread-not-present-mixing-two-section.s b/ld/testsuite/ld-arm/thumb1-noread-not-present-mixing-two-section.s
index ac7c89f..5b14873 100644
--- a/ld/testsuite/ld-arm/thumb1-noread-not-present-mixing-two-section.s
+++ b/ld/testsuite/ld-arm/thumb1-noread-not-present-mixing-two-section.s
@@ -1,5 +1,5 @@
.text
- .section .text.noread
+ .section .text.noread,"axy",%progbits
.arch armv6s-m
.syntax unified
.global _start
diff --git a/ld/testsuite/ld-arm/thumb1-noread-present-one-section.s b/ld/testsuite/ld-arm/thumb1-noread-present-one-section.s
index 4be37d2..203cfd5 100644
--- a/ld/testsuite/ld-arm/thumb1-noread-present-one-section.s
+++ b/ld/testsuite/ld-arm/thumb1-noread-present-one-section.s
@@ -1,5 +1,5 @@
.text
- .section .text.noread
+ .section .text.fetchonly,"axy",%progbits
.arch armv6s-m
.syntax unified
.global _start
diff --git a/ld/testsuite/ld-arm/thumb1-noread-present-two-section.s b/ld/testsuite/ld-arm/thumb1-noread-present-two-section.s
index a97f379..245ab25 100644
--- a/ld/testsuite/ld-arm/thumb1-noread-present-two-section.s
+++ b/ld/testsuite/ld-arm/thumb1-noread-present-two-section.s
@@ -1,5 +1,5 @@
.text
- .section .text.noread.first
+ .section .text.fetchonly.first,"axy",%progbits
.arch armv6s-m
.syntax unified
.global _start
@@ -9,7 +9,7 @@ _start:
bx lr
.text
- .section .text.noread.second
+ .section .text.fetchonly.second,"axy",%progbits
.arch armv6s-m
.syntax unified
.global foo
--
2.6.4