]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add support for an ARM specific 'y' section attribute flag to mark the section as...
authorMickael Guene <mickael.guene@st.com>
Wed, 20 Jan 2016 12:53:50 +0000 (12:53 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 20 Jan 2016 12:53:50 +0000 (12:53 +0000)
bfd/ChangeLog:
      * elf32-arm.c ((elf32_arm_special_sections): Remove catch of noread
      section using '.text.noread' pattern.

gas/ChangeLog:
      * 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:
      * gas/arm/section-execute-only.s: New test case.
      * gas/arm/section-execute-only.d: Expected output.

ld/testsuite/ChangeLog:
      * 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:
      * 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.

18 files changed:
bfd/ChangeLog
bfd/elf32-arm.c
binutils/ChangeLog
binutils/doc/binutils.texi
binutils/objdump.c
binutils/readelf.c
gas/ChangeLog
gas/config/obj-elf.c
gas/config/tc-arm.c
gas/config/tc-arm.h
gas/doc/c-arm.texi
gas/testsuite/gas/arm/section-execute-only.d [new file with mode: 0644]
gas/testsuite/gas/arm/section-execute-only.s [new file with mode: 0644]
ld/ChangeLog
ld/testsuite/ld-arm/thumb1-input-section-flag-match.s
ld/testsuite/ld-arm/thumb1-noread-not-present-mixing-two-section.s
ld/testsuite/ld-arm/thumb1-noread-present-one-section.s
ld/testsuite/ld-arm/thumb1-noread-present-two-section.s

index ed99d928804a227e583960ad56d4c2880774e754..739393d1e9cb4329a608772f396b0ff648b77582 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-20  Mickael Guene  <mickael.guene@st.com>
+
+       * elf32-arm.c (elf32_arm_special_sections): Remove catch of noread
+       section using '.text.noread' pattern.
+
 2016-01-19  John Baldwin  <jhb@FreeBSD.org>
 
        * elf.c (elfcore_grok_note): Recognize NT_FREEBSD_THRMISC notes.
index 1c52526b6115a33af74ca75dde57b81b2c6c771a..39b6153359d1baa5f7203d677ced52310df1adc7 100644 (file)
@@ -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
index 24e2afea4cd10e10ddd68aa5d8954e1481e035fd..2d23f209fc61319a1448a1416033ca75879816b7 100644 (file)
@@ -1,3 +1,14 @@
+2016-01-20  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.
+       * objdump.c (dump_section_header): Display NOREAD attributes as
+       well.
+       * doc/binutils.texi (objdump): Note that it is correct for
+       sections to have both the READONLY and NOREAD attributes.
+
 2016-01-19  John Baldwin  <jhb@FreeBSD.org>
 
        * readelf.c (get_freebsd_elfcore_note_type): Remove unused variable.
index 771100e74b708d772846acab8090949dc3a32981..b17373222e6bc2fd69e6db58a2963c6cd2fbc1be 100644 (file)
@@ -2125,6 +2125,11 @@ although @command{ld} relocates the sections correctly, using @samp{objdump
 Instead, it shows the usual addresses, which are implicit for the
 target.
 
+Note, in some cases it is possible for a section to have both the
+READONLY and the NOREAD attributes set.  In such cases the NOREAD
+attribute takes precedence, but @command{objdump} will report both
+since the exact setting of the flag bits might be important.
+
 @item -H
 @itemx --help
 Print a summary of the options to @command{objdump} and exit.
index fa991a96955ccfb8951fd67f1cc099aa964c08eb..3c94a761a5e02a2529566105ff33d55b7824ea32 100644 (file)
@@ -488,9 +488,23 @@ dump_section_header (bfd *abfd, asection *section,
     }
   PF (SEC_SMALL_DATA, "SMALL_DATA");
   if (bfd_get_flavour (abfd) == bfd_target_coff_flavour)
-    PF (SEC_COFF_SHARED, "SHARED");
+    {
+      PF (SEC_COFF_SHARED, "SHARED");
+      PF (SEC_COFF_NOREAD, "NOREAD");
+    }
+  else if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+    {
+      /* Note - sections can have both the READONLY and NOREAD attributes
+        set.  In this case the NOREAD takes precedence, but we report both
+        since the user may need to know that both bits are set.  */
+      PF (SEC_ELF_NOREAD, "NOREAD");
+    }
   PF (SEC_THREAD_LOCAL, "THREAD_LOCAL");
   PF (SEC_GROUP, "GROUP");
+  if (bfd_get_arch (abfd) == bfd_arch_mep)
+    {
+      PF (SEC_MEP_VLIW, "VLIW");
+    }
 
   if ((section->flags & SEC_LINK_ONCE) != 0)
     {
index b4aaf51ace1502388c1914bee41c393d71723442..b3a28a8d88d8ba69fa11f996b921f36c9349c65d 100644 (file)
@@ -5430,6 +5430,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';
@@ -6006,6 +6009,11 @@ process_section_headers (FILE * file)
        printf (_("Key to Flags:\n\
   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\
index a905d6f44f1f7a9f6228c22e6ef3b3ce543b05f5..75bee536792315f508625db73182fa54883f377c 100644 (file)
@@ -1,3 +1,18 @@
+2016-01-20  Mickael Guene  <mickael.guene@st.com>
+           Terry Guo  <terry.guo@arm.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): Document the 'y' attribute.
+
+       * testsuite/gas/arm/section-execute-only.s: New test case.
+       * testsuite/gas/arm/section-execute-only.d: Expected output.
+
 2016-01-18  Maciej W. Rozycki  <macro@imgtec.com>
 
        * config/tc-mips.c (micromips_insn_length): Remove the mention
index f4726ffcfae73a823fc0d4e20318aa6a182b39e8..6d6d5f3a3fcf06a84a91a0584d5c0f4d730668ae 100644 (file)
 #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);
@@ -673,6 +677,11 @@ obj_elf_change_section (const char *name,
                       || ssect->type == SHT_PREINIT_ARRAY))
            /* 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
            {
index 046abe5b9e66233de7ff84fe64ae39b55d40dcda..4a16267f5396b4f46eb19fb655bbe7614cd52cdd 100644 (file)
@@ -24091,6 +24091,15 @@ arm_fix_adjustable (fixS * fixP)
 #endif /* defined (OBJ_ELF) || defined (OBJ_COFF) */
 
 #ifdef OBJ_ELF
+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;
+}
 
 const char *
 elf32_arm_target_format (void)
index 319b2c2dfef4d8030f4403ea5b18aa0c517684f3..749629c15fe879da0b7c471cae9c4cddd1e303a9 100644 (file)
@@ -114,6 +114,9 @@ extern bfd_boolean tc_start_label_without_colon (void);
 #define tc_frob_fake_label(S) arm_frob_label (S)
 
 #ifdef OBJ_ELF
+#define md_elf_section_letter arm_elf_section_letter
+extern bfd_vma arm_elf_section_letter (int, char **);
+
 #define md_end arm_md_end
 extern void arm_md_end (void);
 bfd_boolean arm_is_eabi (void);
index 4ee6a21598a3a2756232ab0b50fb7ce3709316f5..886b02496e8192d8daad2bd6f5ce70be65629d64 100644 (file)
@@ -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,15 @@ 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
+This letter specifies a text section with NOREAD attribute for
+hardware that supports execute-only memory region.  If not supported
+by hardware a section with this attribute 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 (file)
index 0000000..d45a132
--- /dev/null
@@ -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 (file)
index 0000000..9d5ffc6
--- /dev/null
@@ -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
+
index 67aad579a1e3dce5bb7f2d9f3a1762404bcbb58e..94b6f47d6e70b11ae0b65fe31d96315d70037d2b 100644 (file)
@@ -1,3 +1,11 @@
+2016-01-20  Mickael Guene  <mickael.guene@st.com>
+
+       * testsuite/ld-arm/thumb1-noread-not-present-mixing-two-section.s:
+       Add 'y' attribute usage.
+       * testsuite/ld-arm/thumb1-noread-present-one-section.s: Likewise.
+       * testsuite/ld-arm/thumb1-noread-present-two-section.s: Likewise.
+       * testsuite/ld-arm/thumb1-input-section-flag-match.s: Likewise.
+
 2016-01-19  Nick Clifton  <nickc@redhat.com>
 
        * testsuite/ld-elf/pr18735.d: Allow for extra symbols between
index ac7c89f016ce2c0dfac912ff03c636f724261978..6f1ad62ddf9ad5592df6d8778689618cae311d01 100644 (file)
@@ -1,5 +1,5 @@
        .text
-       .section .text.noread
+       .section .text.fetchonly,"axy",%progbits
        .arch armv6s-m
        .syntax unified
        .global _start
index ac7c89f016ce2c0dfac912ff03c636f724261978..5b14873f44821936b50b7b4991b401fec6ad68ec 100644 (file)
@@ -1,5 +1,5 @@
        .text
-       .section .text.noread
+       .section .text.noread,"axy",%progbits
        .arch armv6s-m
        .syntax unified
        .global _start
index 4be37d24d7d7ef263958a88f2af05a225bc8a879..203cfd5428cfb1edca053e59ae69e71419c1aee8 100644 (file)
@@ -1,5 +1,5 @@
        .text
-       .section .text.noread
+       .section .text.fetchonly,"axy",%progbits
        .arch armv6s-m
        .syntax unified
        .global _start
index a97f37999695c179394bf7c06d9955317e3ad969..245ab255bf3c4e72efd705da81cecacc0dea58ec 100644 (file)
@@ -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