include/ChangeLog
authorCatherine Moore <clm@redhat.com>
Mon, 11 Jul 2011 15:03:09 +0000 (15:03 +0000)
committerCatherine Moore <clm@redhat.com>
Mon, 11 Jul 2011 15:03:09 +0000 (15:03 +0000)
2011-07-11  Catherine Moore  <clm@codesourcery.com>

* bfdlink.h (flag_type): New enumeration.
(flag_info_list): New structure.
(flag_info): New structure.

bfd/ChangeLog
2011-07-11  Catherine Moore  <clm@codesourcery.com>

* aout-adobe.c (aout_32_bfd_lookup_section_flags): New definition.
* aout-target.h (MY_bfd_lookup_section_flags): New definition.
* aout-tic30.c (MY_bfd_lookup_section_flags): New definition.
        * bfd-in2.h: Regenerated.
* bfd.c (bfd_lookup_section_flags): New definition.
* binary.c (binary_bfd_lookup_section_flags): New definition.
* bout.c (b_out_bfd_lookup_section_flags): New definition.
* coff-alpha.c (_bfd_ecoff_bfd_lookup_section_flags): New definition.
* coff-mips.c (_bfd_ecoff_bfd_lookup_section_flags): New definition.
* coff-rs6000.c (rs6000coff_vec): Include
bfd_generic_lookup_section_flags.
(pmac_xcoff_vec): Likewise.
* coffcode.h (coff_bfd_lookup_section_flags): New definition.
* coff64-rs6000.c (rs6000coff64_vec): Include
bfd_generic_lookup_section_flags.
(aix5coff64_vec): Likewise.
* ecoff.c (bfd_debug_section): Initialize flag_info field.
* elf-bfd.h (elf_backend_lookup_section_flags_hook): Declare.
(bfd_elf_lookup_section_flags): Declare.
* elflink.c (bfd_elf_lookup_section_flags): New function.
* elfxx-target.h (bfd_elfNN_bfd_lookup_section_flags): Define.
(elf_backend_lookup_section_flags_hook): Define.
(elf_backend_data): Add elf_backend_lookup_section_flags_hook.
* i386msdos.c (msdos_bfd_lookup_section_flags): New define.
* i386os9k.c (os9k_bfd_lookup_section_flags): New define.
* ieee.c (ieee_bfd_lookup_section_flags): New define.
* ihex.c (ihex_bfd_lookup_section_flags): New define.
* libbfd-in.h (_bfd_nolink_bfd_lookup_section_flags): Declare.
(bfd_generic_lookup_section_flags): Declare.
* libbfd.h: Regenerated.
* mach-o-target.c (bfd_mach_o_bfd_lookup_section_flags): New.
* mmo.c (mmo_bfd_lookup_section_flags): New definition.
* nlm-target.h (nlm_bfd_lookup_section_flags): New definition.
* oasys.c (oasys_bfd_lookup_section_flags): New definition.
* pef.c (bfd_pef_bfd_lookup_section_flags): New definition.
* plugin.c (bfd_plugin_bfd_lookup_section_flags): New definition.
* ppcboot.c (ppcboot_bfd_lookup_section_flags): New definition.
* reloc.c (bfd_generic_lookup_section_flags): New function.
* som.c (som_bfd_lookup_section_flags): New definition.
* srec.c (srec_bfd_lookup_section_flags): New definition.
* targets.c (flag_info): Declare.
(NAME##_bfd_lookup_section_flags): Add to LINK jump table.
(_bfd_lookup_section_flags): New.
* tekhex.c (tekhex_bfd_lookup_section_flags): New definition.
* versados.c (versados_bfd_lookup_section_flags): New definition.
* vms-alpha.c (alpha_vms_bfd_lookup_section_flag): New definition.
* xsym.c (bfd_sym_bfd_lookup_section_flags): New definition.

ld/ChangeLog
2011-07-11  Catherine Moore  <clm@codesourcery.com>

* ld.h (section_flag_list): Add field to struct wildcard_spec.
* ld.texinfo (INPUT_SECTION_FLAGS): Document.
* ldgram.y (flag_info_list, flag_info): Add to union.
(INPUT_SECTION_FLAGS): New token.
(wildcard_spec): Initialize section_flag_list to NULL for
each alternative.
(sect_flag_list, sect_flags): New rules.
(input_section_spec_no_keep): Add alternatives to recognize
sect_flags.
* ldlang.c (walk_wild_consider_section): Initialize
section_flag_info field of the section struct.
(lang_add_section): Check input section flags.
(lang_add_wild): Initialize section_flag_list field of
the statement struct.
* ldlang.h (lang_input_statement_struct): Add section_flag_list field.
(lang_wild_statement_struct): Likewise.
* ldlex.l (INPUT_SECTION_FLAGS): New token.
* mri.c (mri_draw_tree): Initialize section_flag_list to NULL.
* NEWS: Announce INPUT_SECTION_FLAGS enhancement.

ld/testsuite/ChangeLog
2011-07-11 Catherine Moore  <clm@cm00re.com>

* ld-scripts/section-flags-1.s: New.
* ld-scripts/section-flags-1.t: New.
* ld-scripts/section-flags-2.s: New.
* ld-scripts/section-flags-2.t: New.
* ld-scripts/section-flags.exp: New.

57 files changed:
bfd/ChangeLog
bfd/aout-adobe.c
bfd/aout-target.h
bfd/aout-tic30.c
bfd/bfd-in2.h
bfd/bfd.c
bfd/binary.c
bfd/bout.c
bfd/coff-alpha.c
bfd/coff-mips.c
bfd/coff-rs6000.c
bfd/coff64-rs6000.c
bfd/coffcode.h
bfd/ecoff.c
bfd/elf-bfd.h
bfd/elflink.c
bfd/elfxx-target.h
bfd/i386msdos.c
bfd/i386os9k.c
bfd/ieee.c
bfd/ihex.c
bfd/libbfd-in.h
bfd/libbfd.h
bfd/mach-o-target.c
bfd/mmo.c
bfd/nlm-target.h
bfd/oasys.c
bfd/pef.c
bfd/plugin.c
bfd/ppcboot.c
bfd/reloc.c
bfd/section.c
bfd/som.c
bfd/srec.c
bfd/targets.c
bfd/tekhex.c
bfd/versados.c
bfd/vms-alpha.c
bfd/xsym.c
include/ChangeLog
include/bfdlink.h
include/elf/ppc.h
ld/ChangeLog
ld/NEWS
ld/ld.h
ld/ld.texinfo
ld/ldgram.y
ld/ldlang.c
ld/ldlang.h
ld/ldlex.l
ld/mri.c
ld/testsuite/ChangeLog
ld/testsuite/ld-scripts/section-flags-1.s [new file with mode: 0644]
ld/testsuite/ld-scripts/section-flags-1.t [new file with mode: 0644]
ld/testsuite/ld-scripts/section-flags-2.s [new file with mode: 0644]
ld/testsuite/ld-scripts/section-flags-2.t [new file with mode: 0644]
ld/testsuite/ld-scripts/section-flags.exp [new file with mode: 0644]

index e469ef28755f562ea6b51802e7c5a4bf60eb1839..e20d3db2d0c53d77eb79a58a1a2470cc02ca50ec 100644 (file)
@@ -1,3 +1,53 @@
+2011-07-11  Catherine Moore  <clm@codesourcery.com>
+
+       * aout-adobe.c (aout_32_bfd_lookup_section_flags): New definition.
+       * aout-target.h (MY_bfd_lookup_section_flags): New definition.
+       * aout-tic30.c (MY_bfd_lookup_section_flags): New definition.
+        * bfd-in2.h: Regenerated.
+       * bfd.c (bfd_lookup_section_flags): New definition.
+       * binary.c (binary_bfd_lookup_section_flags): New definition.
+       * bout.c (b_out_bfd_lookup_section_flags): New definition.
+       * coff-alpha.c (_bfd_ecoff_bfd_lookup_section_flags): New definition.
+       * coff-mips.c (_bfd_ecoff_bfd_lookup_section_flags): New definition.
+       * coff-rs6000.c (rs6000coff_vec): Include
+       bfd_generic_lookup_section_flags.
+       (pmac_xcoff_vec): Likewise.
+       * coffcode.h (coff_bfd_lookup_section_flags): New definition.
+       * coff64-rs6000.c (rs6000coff64_vec): Include
+       bfd_generic_lookup_section_flags.
+       (aix5coff64_vec): Likewise.
+       * ecoff.c (bfd_debug_section): Initialize flag_info field.
+       * elf-bfd.h (elf_backend_lookup_section_flags_hook): Declare.
+       (bfd_elf_lookup_section_flags): Declare.
+       * elflink.c (bfd_elf_lookup_section_flags): New function.
+       * elfxx-target.h (bfd_elfNN_bfd_lookup_section_flags): Define.
+       (elf_backend_lookup_section_flags_hook): Define.
+       (elf_backend_data): Add elf_backend_lookup_section_flags_hook.
+       * i386msdos.c (msdos_bfd_lookup_section_flags): New define.
+       * i386os9k.c (os9k_bfd_lookup_section_flags): New define.
+       * ieee.c (ieee_bfd_lookup_section_flags): New define.
+       * ihex.c (ihex_bfd_lookup_section_flags): New define.
+       * libbfd-in.h (_bfd_nolink_bfd_lookup_section_flags): Declare.
+       (bfd_generic_lookup_section_flags): Declare.
+       * libbfd.h: Regenerated.
+       * mach-o-target.c (bfd_mach_o_bfd_lookup_section_flags): New.
+       * mmo.c (mmo_bfd_lookup_section_flags): New definition.
+       * nlm-target.h (nlm_bfd_lookup_section_flags): New definition.
+       * oasys.c (oasys_bfd_lookup_section_flags): New definition.
+       * pef.c (bfd_pef_bfd_lookup_section_flags): New definition.
+       * plugin.c (bfd_plugin_bfd_lookup_section_flags): New definition.
+       * ppcboot.c (ppcboot_bfd_lookup_section_flags): New definition.
+       * reloc.c (bfd_generic_lookup_section_flags): New function.
+       * som.c (som_bfd_lookup_section_flags): New definition.
+       * srec.c (srec_bfd_lookup_section_flags): New definition.
+       * targets.c (flag_info): Declare.
+       (NAME##_bfd_lookup_section_flags): Add to LINK jump table.
+       (_bfd_lookup_section_flags): New.
+       * tekhex.c (tekhex_bfd_lookup_section_flags): New definition.
+       * versados.c (versados_bfd_lookup_section_flags): New definition.
+       * vms-alpha.c (alpha_vms_bfd_lookup_section_flag): New definition.
+       * xsym.c (bfd_sym_bfd_lookup_section_flags): New definition.
+
 2011-07-11  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/12978
index bd38ea83902552e0289fd0147d69c5d7cafbf7b0..c8331d8c5d4c8db9e111cc671970a059f1913be7 100644 (file)
@@ -459,6 +459,7 @@ aout_adobe_sizeof_headers (bfd *ignore_abfd ATTRIBUTE_UNUSED,
 #define aout_32_get_section_contents_in_window      _bfd_generic_get_section_contents_in_window
 #define aout_32_bfd_relax_section                   bfd_generic_relax_section
 #define aout_32_bfd_gc_sections                     bfd_generic_gc_sections
+#define aout_32_bfd_lookup_section_flags           bfd_generic_lookup_section_flags
 #define aout_32_bfd_merge_sections                 bfd_generic_merge_sections
 #define aout_32_bfd_is_group_section               bfd_generic_is_group_section
 #define aout_32_bfd_discard_group                  bfd_generic_discard_group
index 5c0d2ae3551845a0fe2e16e24ec5caf3506e38c6..f6e8bd2e2dc00017896c1636332659095e44da78 100644 (file)
@@ -486,6 +486,9 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 #ifndef MY_bfd_gc_sections
 #define MY_bfd_gc_sections bfd_generic_gc_sections
 #endif
+#ifndef MY_bfd_lookup_section_flags
+#define MY_bfd_lookup_section_flags bfd_generic_lookup_section_flags
+#endif
 #ifndef MY_bfd_merge_sections
 #define MY_bfd_merge_sections bfd_generic_merge_sections
 #endif
index 30900ba388b9f00252651a68d12afbbb23bd407d..0b0117729600b49f6ec8a2b183eabca895118ed5 100644 (file)
@@ -944,6 +944,9 @@ tic30_aout_set_arch_mach (bfd *abfd,
 #ifndef MY_bfd_gc_sections
 #define MY_bfd_gc_sections bfd_generic_gc_sections
 #endif
+#ifndef MY_bfd_lookup_section_flags
+#define MY_bfd_lookup_section_flags bfd_generic_lookup_section_flags
+#endif
 #ifndef MY_bfd_merge_sections
 #define MY_bfd_merge_sections bfd_generic_merge_sections
 #endif
index da4688c48fdf26418e93f1e30836a1f3bc50acab..867d052c781460ce95b0b3684fc90ca2e2a9cdad 100644 (file)
@@ -1514,6 +1514,9 @@ typedef struct bfd_section
   /* The BFD which owns the section.  */
   bfd *owner;
 
+  /* INPUT_SECTION_FLAGS if specified in the linker script.  */
+  struct flag_info *section_flag_info;
+
   /* A symbol which points at this section only.  */
   struct bfd_symbol *symbol;
   struct bfd_symbol **symbol_ptr_ptr;
@@ -1692,6 +1695,9 @@ extern asection bfd_ind_section;
   /* target_index, used_by_bfd, constructor_chain, owner,          */  \
      0,            NULL,        NULL,              NULL,               \
                                                                        \
+  /* flag_info,                                                    */  \
+     NULL,                                                             \
+                                                                       \
   /* symbol,                    symbol_ptr_ptr,                    */  \
      (struct bfd_symbol *) SYM, &SEC.symbol,                           \
                                                                        \
@@ -5571,6 +5577,9 @@ bfd_boolean bfd_set_private_flags (bfd *abfd, flagword flags);
 #define bfd_gc_sections(abfd, link_info) \
        BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info))
 
+#define bfd_lookup_section_flags(link_info, flag_info) \
+       BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info))
+
 #define bfd_merge_sections(abfd, link_info) \
        BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info))
 
@@ -5728,6 +5737,9 @@ enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
 typedef struct bfd_link_info _bfd_link_info;
 struct already_linked;
 
+/* Forward declaration.  */
+typedef struct flag_info flag_info;
+
 typedef struct bfd_target
 {
   /* Identifies the kind of target, e.g., SunOS4, Ultrix, etc.  */
@@ -5997,6 +6009,7 @@ typedef struct bfd_target
   NAME##_bfd_final_link, \
   NAME##_bfd_link_split_section, \
   NAME##_bfd_gc_sections, \
+  NAME##_bfd_lookup_section_flags, \
   NAME##_bfd_merge_sections, \
   NAME##_bfd_is_group_section, \
   NAME##_bfd_discard_group, \
@@ -6041,6 +6054,10 @@ typedef struct bfd_target
   /* Remove sections that are not referenced from the output.  */
   bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *);
 
+  /* Sets the bitmask of allowed and disallowed section flags.  */
+  void (*_bfd_lookup_section_flags) (struct bfd_link_info *,
+                                     struct flag_info *);
+
   /* Attempt to merge SEC_MERGE sections.  */
   bfd_boolean (*_bfd_merge_sections) (bfd *, struct bfd_link_info *);
 
index b3e2c47289b37b75c921d61e694922a981550a8b..7c14c7a00a6e885aa98443113456b240bd04c8b5 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1374,6 +1374,9 @@ DESCRIPTION
 .#define bfd_gc_sections(abfd, link_info) \
 .      BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info))
 .
+.#define bfd_lookup_section_flags(link_info, flag_info) \
+.      BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info))
+.
 .#define bfd_merge_sections(abfd, link_info) \
 .      BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info))
 .
index ad93354016c04b11009c35fbdb8fcf8d4824db14..700c862f93d68fd5270482eb73703147a2a9d279 100644 (file)
@@ -299,6 +299,7 @@ binary_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define binary_bfd_get_relocated_section_contents  bfd_generic_get_relocated_section_contents
 #define binary_bfd_relax_section                   bfd_generic_relax_section
 #define binary_bfd_gc_sections                     bfd_generic_gc_sections
+#define binary_bfd_lookup_section_flags            bfd_generic_lookup_section_flags
 #define binary_bfd_merge_sections                  bfd_generic_merge_sections
 #define binary_bfd_is_group_section                bfd_generic_is_group_section
 #define binary_bfd_discard_group                   bfd_generic_discard_group
index b76191b0484782ce5e93c44016b992073f834056..cfd4abb01911819cb7b93ce131d04b3f8185164f 100644 (file)
@@ -1387,6 +1387,7 @@ b_out_bfd_get_relocated_section_contents (bfd *output_bfd,
 #define b_out_bfd_final_link                   _bfd_generic_final_link
 #define b_out_bfd_link_split_section           _bfd_generic_link_split_section
 #define b_out_bfd_gc_sections                  bfd_generic_gc_sections
+#define b_out_bfd_lookup_section_flags         bfd_generic_lookup_section_flags
 #define b_out_bfd_merge_sections               bfd_generic_merge_sections
 #define b_out_bfd_is_group_section             bfd_generic_is_group_section
 #define b_out_bfd_discard_group                bfd_generic_discard_group
index c4dfd8f7fbd419e8b006377649aa0e1c5716d8b5..2233a335cbf739fa2186dfd6087041e57690752f 100644 (file)
@@ -2393,6 +2393,9 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data =
 #define _bfd_ecoff_get_section_contents_in_window \
   _bfd_generic_get_section_contents_in_window
 
+/* Input section flag lookup is generic.  */
+#define _bfd_ecoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags
+
 /* Relaxing sections is generic.  */
 #define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section
 #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections
index cbc172f7c00b9d88df5f4330c276a2a3d64e1e36..9f8b90dcef8285f1bcf740e99f27fb6cc0bb7725 100644 (file)
@@ -1410,6 +1410,9 @@ static const struct ecoff_backend_data mips_ecoff_backend_data =
 /* GC of sections is not done.  */
 #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections
 
+/* Input section flags is not implemented.  */
+#define _bfd_ecoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags
+
 /* Merging of sections is not done.  */
 #define _bfd_ecoff_bfd_merge_sections bfd_generic_merge_sections
 
index c1b5c89cc809a67f2b3f68cdfe3555e6c4f99f65..5d9b5aeb5323a951c50e8211178ad6c93d52ac4a 100644 (file)
@@ -4102,6 +4102,7 @@ const bfd_target rs6000coff_vec =
     _bfd_xcoff_bfd_final_link,
     _bfd_generic_link_split_section,
     bfd_generic_gc_sections,
+    bfd_generic_lookup_section_flags,
     bfd_generic_merge_sections,
     bfd_generic_is_group_section,
     bfd_generic_discard_group,
@@ -4356,6 +4357,7 @@ const bfd_target pmac_xcoff_vec =
     _bfd_xcoff_bfd_final_link,
     _bfd_generic_link_split_section,
     bfd_generic_gc_sections,
+    bfd_generic_lookup_section_flags,
     bfd_generic_merge_sections,
     bfd_generic_is_group_section,
     bfd_generic_discard_group,
index ef4dfbae582bfd152a0b242f3c0b53d80f42b8bd..031385deeedd26eeab8504ced446842cad2ac7f8 100644 (file)
@@ -2738,6 +2738,7 @@ const bfd_target rs6000coff64_vec =
     _bfd_xcoff_bfd_final_link,
     _bfd_generic_link_split_section,
     bfd_generic_gc_sections,
+    bfd_generic_lookup_section_flags,
     bfd_generic_merge_sections,
     bfd_generic_is_group_section,
     bfd_generic_discard_group,
@@ -2994,6 +2995,7 @@ const bfd_target aix5coff64_vec =
     _bfd_xcoff_bfd_final_link,
     _bfd_generic_link_split_section,
     bfd_generic_gc_sections,
+    bfd_generic_lookup_section_flags,
     bfd_generic_merge_sections,
     bfd_generic_is_group_section,
     bfd_generic_discard_group,
index e71aadd30430bd903d652505e288b6a5555c68aa..2313dc50a2d61b2e047c4b72b1d17a1095711752 100644 (file)
@@ -5652,6 +5652,10 @@ static bfd_coff_backend_data ticoff1_swap_table =
 #define coff_bfd_gc_sections               bfd_generic_gc_sections
 #endif
 
+#ifndef coff_bfd_lookup_section_flags
+#define coff_bfd_lookup_section_flags      bfd_generic_lookup_section_flags
+#endif
+
 #ifndef coff_bfd_merge_sections
 #define coff_bfd_merge_sections                    bfd_generic_merge_sections
 #endif
index efcb9bf75cd3dc081e3a281fbef2e646d497f7fb..b76266d26f7de196ac081b1c28a0c126c00d28ca 100644 (file)
@@ -73,6 +73,8 @@ static asection bfd_debug_section =
      0,       NULL,         0,
   /* target_index, used_by_bfd, constructor_chain, owner,          */
      0,            NULL,        NULL,              NULL,
+  /* flag_info,                                                    */
+     NULL,
   /* symbol,                                                       */
      NULL,
   /* symbol_ptr_ptr,                                               */
index b2075a5677b71ad6efba049dd0360e5a2ad35971..08da2aeed806b519ef7c7c312014177baec2d44b 100644 (file)
@@ -1112,6 +1112,11 @@ struct elf_backend_data
   char *(*elf_backend_write_core_note)
     (bfd *abfd, char *buf, int *bufsiz, int note_type, ...);
 
+  /* This function, if defined, is called to convert target-specific
+     section flag names into hex values.  */
+  flagword (*elf_backend_lookup_section_flags_hook)
+    (char *);
+
   /* This function returns class of a reloc type.  */
   enum elf_reloc_type_class (*elf_backend_reloc_type_class)
     (const Elf_Internal_Rela *);
@@ -2193,6 +2198,9 @@ extern bfd_boolean _bfd_elf_is_function_type (unsigned int);
 
 extern int bfd_elf_get_default_section_type (flagword);
 
+extern void bfd_elf_lookup_section_flags
+  (struct bfd_link_info *, struct flag_info *);
+
 extern Elf_Internal_Phdr * _bfd_elf_find_segment_containing_section
   (bfd * abfd, asection * section);
 
index 238a4aab1a7a769068e8e64de7352d88dc2a6145..e2cb28cc8e23f8acf0dbc608455f018dcd641479 100644 (file)
@@ -12167,6 +12167,83 @@ bfd_elf_gc_record_vtentry (bfd *abfd ATTRIBUTE_UNUSED,
   return TRUE;
 }
 
+/* Map an ELF section header flag to its corresponding string.  */
+typedef struct
+{
+  char *flag_name;
+  flagword flag_value;
+} elf_flags_to_name_table;
+
+static elf_flags_to_name_table elf_flags_to_names [] =
+{
+  { "SHF_WRITE", SHF_WRITE },
+  { "SHF_ALLOC", SHF_ALLOC },
+  { "SHF_EXECINSTR", SHF_EXECINSTR },
+  { "SHF_MERGE", SHF_MERGE },
+  { "SHF_STRINGS", SHF_STRINGS },
+  { "SHF_INFO_LINK", SHF_INFO_LINK},
+  { "SHF_LINK_ORDER", SHF_LINK_ORDER},
+  { "SHF_OS_NONCONFORMING", SHF_OS_NONCONFORMING},
+  { "SHF_GROUP", SHF_GROUP },
+  { "SHF_TLS", SHF_TLS },
+  { "SHF_MASKOS", SHF_MASKOS },
+  { "SHF_EXCLUDE", SHF_EXCLUDE },
+};
+
+void
+bfd_elf_lookup_section_flags (struct bfd_link_info *info,
+                             struct flag_info *finfo)
+{
+  bfd *output_bfd = info->output_bfd;
+  const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
+  struct flag_info_list *tf = finfo->flag_list;
+  int with_hex = 0;
+  int without_hex = 0;
+
+  for (tf = finfo->flag_list; tf != NULL; tf = tf->next)
+    {
+      int i;
+      if (bed->elf_backend_lookup_section_flags_hook)
+       {
+         flagword hexval =
+            (*bed->elf_backend_lookup_section_flags_hook) ((char *) tf->name);
+
+         if (hexval != 0)
+           {
+             if (tf->with == with_flags)
+               with_hex |= hexval;
+             else if (tf->with == without_flags)
+               without_hex |= hexval;
+             tf->valid = TRUE;
+             continue;
+           }
+       }
+      for (i = 0; i < 12; i++)
+       {
+         if (!strcmp (tf->name, elf_flags_to_names[i].flag_name))
+           {
+             if (tf->with == with_flags)
+               with_hex |= elf_flags_to_names[i].flag_value;
+             else if (tf->with == without_flags)
+               without_hex |= elf_flags_to_names[i].flag_value;
+             tf->valid = TRUE;
+             continue;
+           }
+       }
+      if (tf->valid == FALSE)
+       {
+         info->callbacks->einfo 
+               (_("Unrecognized INPUT_SECTION_FLAG %s\n"), tf->name);
+         return;
+       }
+    }
+ finfo->flags_initialized = TRUE;
+ finfo->only_with_flags |= with_hex;
+ finfo->not_with_flags |= without_hex;
+
+ return;
+}
+
 struct alloc_got_off_arg {
   bfd_vma gotoff;
   struct bfd_link_info *info;
index b033c17655021b30006c7b4040861b6783ea79f8..b51ac9fde61569e419266ddbb36c6d8c9392ce1f 100644 (file)
 #define bfd_elfNN_bfd_define_common_symbol bfd_generic_define_common_symbol
 #endif
 
+#ifndef bfd_elfNN_bfd_lookup_section_flags
+#define bfd_elfNN_bfd_lookup_section_flags bfd_elf_lookup_section_flags
+#endif
+
 #ifndef bfd_elfNN_bfd_make_debug_symbol
 #define bfd_elfNN_bfd_make_debug_symbol \
   ((asymbol * (*) (bfd *, void *, unsigned long)) bfd_nullvoidptr)
 #ifndef elf_backend_write_core_note
 #define elf_backend_write_core_note            NULL
 #endif
+#ifndef elf_backend_lookup_section_flags_hook
+#define elf_backend_lookup_section_flags_hook  NULL
+#endif
 #ifndef elf_backend_reloc_type_class
 #define elf_backend_reloc_type_class           _bfd_elf_reloc_type_class
 #endif
@@ -717,6 +724,7 @@ static struct elf_backend_data elfNN_bed =
   elf_backend_grok_prstatus,
   elf_backend_grok_psinfo,
   elf_backend_write_core_note,
+  elf_backend_lookup_section_flags_hook,
   elf_backend_reloc_type_class,
   elf_backend_discard_info,
   elf_backend_ignore_discarded_relocs,
index 9ff5fd379cea65b0f3533d5c8f50673f8e0a43a4..b67b13e229731448982aea0141d8e86a884bafdf 100644 (file)
@@ -143,6 +143,7 @@ msdos_set_section_contents (bfd *abfd,
   bfd_generic_get_relocated_section_contents
 #define msdos_bfd_relax_section bfd_generic_relax_section
 #define msdos_bfd_gc_sections bfd_generic_gc_sections
+#define msdos_bfd_lookup_section_flags bfd_generic_lookup_section_flags
 #define msdos_bfd_merge_sections bfd_generic_merge_sections
 #define msdos_bfd_is_group_section bfd_generic_is_group_section
 #define msdos_bfd_discard_group bfd_generic_discard_group
index 5cbf927103fdf536fad339f3ac4da02e72cd9161..3beb8a3c1e81eb9295b2733af0dddf3d71aeaad8 100644 (file)
@@ -167,6 +167,7 @@ os9k_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
   bfd_generic_get_relocated_section_contents
 #define os9k_bfd_relax_section bfd_generic_relax_section
 #define os9k_bfd_gc_sections bfd_generic_gc_sections
+#define os9k_bfd_lookup_section_flags bfd_generic_lookup_section_flags
 #define os9k_bfd_merge_sections bfd_generic_merge_sections
 #define os9k_bfd_is_group_section bfd_generic_is_group_section
 #define os9k_bfd_discard_group bfd_generic_discard_group
index 9494b35b66edc724ee73e97a8c4c9f995fdc9560..de1e926721164cf32fdd7bddb1aae138b5e381e0 100644 (file)
@@ -3772,6 +3772,7 @@ ieee_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
   bfd_generic_get_relocated_section_contents
 #define ieee_bfd_relax_section bfd_generic_relax_section
 #define ieee_bfd_gc_sections bfd_generic_gc_sections
+#define ieee_bfd_lookup_section_flags bfd_generic_lookup_section_flags
 #define ieee_bfd_merge_sections bfd_generic_merge_sections
 #define ieee_bfd_is_group_section bfd_generic_is_group_section
 #define ieee_bfd_discard_group bfd_generic_discard_group
index a92baafc7603fd99938496f68ee8470a430da396..09f756a1c2c11e57c5da15a6ff96491275575b86 100644 (file)
@@ -930,6 +930,7 @@ ihex_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define ihex_bfd_get_relocated_section_contents   bfd_generic_get_relocated_section_contents
 #define ihex_bfd_relax_section                    bfd_generic_relax_section
 #define ihex_bfd_gc_sections                      bfd_generic_gc_sections
+#define ihex_bfd_lookup_section_flags             bfd_generic_lookup_section_flags
 #define ihex_bfd_merge_sections                   bfd_generic_merge_sections
 #define ihex_bfd_is_group_section                 bfd_generic_is_group_section
 #define ihex_bfd_discard_group                    bfd_generic_discard_group
index a80687e2f634fb643ac0247d332269d0d38b8044..0c98b47cbc58d13d77bec33445fc32a70b41727c 100644 (file)
@@ -453,6 +453,9 @@ extern bfd_boolean _bfd_generic_set_section_contents
 #define _bfd_nolink_bfd_gc_sections \
   ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \
    bfd_false)
+#define _bfd_nolink_bfd_lookup_section_flags \
+  ((void (*) (struct bfd_link_info *, struct flag_info *)) \
+   bfd_0)
 #define _bfd_nolink_bfd_merge_sections \
   ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \
    bfd_false)
index c72ff16442f445cb7734162880c80457c915e613..25eba0f128110d2bcec4a6bc8a110e5bc53a2bab 100644 (file)
@@ -458,6 +458,9 @@ extern bfd_boolean _bfd_generic_set_section_contents
 #define _bfd_nolink_bfd_gc_sections \
   ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \
    bfd_false)
+#define _bfd_nolink_bfd_lookup_section_flags \
+  ((void (*) (struct bfd_link_info *, struct flag_info *)) \
+   bfd_0)
 #define _bfd_nolink_bfd_merge_sections \
   ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \
    bfd_false)
@@ -2469,6 +2472,9 @@ bfd_boolean bfd_generic_relax_section
 bfd_boolean bfd_generic_gc_sections
    (bfd *, struct bfd_link_info *);
 
+void bfd_generic_lookup_section_flags
+   (struct bfd_link_info *, struct flag_info *);
+
 bfd_boolean bfd_generic_merge_sections
    (bfd *, struct bfd_link_info *);
 
index 32dc335111ceca5e074afe5d7fbf6493ea0181ab..eb7cb53cd49d2c822f84dac3176e12f412a68397 100644 (file)
@@ -51,6 +51,7 @@
 #define bfd_mach_o_bfd_set_private_flags              _bfd_generic_bfd_set_private_flags
 #define bfd_mach_o_get_section_contents               _bfd_generic_get_section_contents
 #define bfd_mach_o_bfd_gc_sections                    bfd_generic_gc_sections
+#define bfd_mach_o_bfd_lookup_section_flags           bfd_generic_lookup_section_flags
 #define bfd_mach_o_bfd_merge_sections                 bfd_generic_merge_sections
 #define bfd_mach_o_bfd_is_group_section               bfd_generic_is_group_section
 #define bfd_mach_o_bfd_discard_group                  bfd_generic_discard_group
index c22790dec2e158aee5a2e61d6647c9b18e3f4cfc..dc45f31b705e34c1f41449249f98b56d712fea0d 100644 (file)
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -3190,6 +3190,7 @@ mmo_write_object_contents (bfd *abfd)
 #define mmo_bfd_get_relocated_section_contents \
   bfd_generic_get_relocated_section_contents
 #define mmo_bfd_gc_sections bfd_generic_gc_sections
+#define mmo_bfd_lookup_section_flags bfd_generic_lookup_section_flags
 #define mmo_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
 #define mmo_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
 #define mmo_bfd_link_add_symbols _bfd_generic_link_add_symbols
index f38b16ec8e8615d54363cc040d3ce243d83cc6cb..9a3b7bef09e29a8b6eb3026ecf19a9625977c2c7 100644 (file)
@@ -45,6 +45,7 @@
 #define nlm_bfd_get_relocated_section_contents  bfd_generic_get_relocated_section_contents
 #define nlm_bfd_relax_section                   bfd_generic_relax_section
 #define nlm_bfd_gc_sections                     bfd_generic_gc_sections
+#define nlm_bfd_lookup_section_flags           bfd_generic_lookup_section_flags
 #define nlm_bfd_merge_sections                  bfd_generic_merge_sections
 #define nlm_bfd_is_group_section                bfd_generic_is_group_section
 #define nlm_bfd_discard_group                   bfd_generic_discard_group
index e58f0d0d6ab7f537c9776f0f570a552078b54c4d..11d24401fe188b2874dd25298d47865887c0521a 100644 (file)
@@ -1196,6 +1196,7 @@ oasys_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
 #define oasys_bfd_get_relocated_section_contents   bfd_generic_get_relocated_section_contents
 #define oasys_bfd_relax_section                    bfd_generic_relax_section
 #define oasys_bfd_gc_sections                      bfd_generic_gc_sections
+#define oasys_bfd_lookup_section_flags             bfd_generic_lookup_section_flags
 #define oasys_bfd_merge_sections                   bfd_generic_merge_sections
 #define oasys_bfd_is_group_section                 bfd_generic_is_group_section
 #define oasys_bfd_discard_group                    bfd_generic_discard_group
index 6db730132e998588acb852a67bc260afbb108564..d4ad33ad37b75b6cd7189448c722b41608a59ff8 100644 (file)
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -48,6 +48,7 @@
 #define bfd_pef_bfd_get_relocated_section_contents  bfd_generic_get_relocated_section_contents
 #define bfd_pef_bfd_relax_section                   bfd_generic_relax_section
 #define bfd_pef_bfd_gc_sections                     bfd_generic_gc_sections
+#define bfd_pef_bfd_lookup_section_flags            bfd_generic_lookup_section_flags
 #define bfd_pef_bfd_merge_sections                  bfd_generic_merge_sections
 #define bfd_pef_bfd_is_group_section               bfd_generic_is_group_section
 #define bfd_pef_bfd_discard_group                   bfd_generic_discard_group
index 5d34f859b75f0e8eab12e80d3e12ea9ed425a7e3..064e2731282fc43f2698a098614af937d8f6db50 100644 (file)
@@ -63,6 +63,7 @@
 #define bfd_plugin_bfd_final_link                     _bfd_generic_final_link
 #define bfd_plugin_bfd_link_split_section             _bfd_generic_link_split_section
 #define bfd_plugin_bfd_gc_sections                    bfd_generic_gc_sections
+#define bfd_plugin_bfd_lookup_section_flags           bfd_generic_lookup_section_flags
 #define bfd_plugin_bfd_merge_sections                 bfd_generic_merge_sections
 #define bfd_plugin_bfd_is_group_section               bfd_generic_is_group_section
 #define bfd_plugin_bfd_discard_group                  bfd_generic_discard_group
index a97043695ee08be2ad3b398cebb480f9d4e83f7d..c2b4c3be795299aba901111bbc0986d1fa5fefe2 100644 (file)
@@ -470,6 +470,7 @@ ppcboot_bfd_print_private_bfd_data (abfd, farg)
   bfd_generic_get_relocated_section_contents
 #define ppcboot_bfd_relax_section bfd_generic_relax_section
 #define ppcboot_bfd_gc_sections bfd_generic_gc_sections
+#define ppcboot_bfd_lookup_section_flags bfd_generic_lookup_section_flags
 #define ppcboot_bfd_merge_sections bfd_generic_merge_sections
 #define ppcboot_bfd_is_group_section bfd_generic_is_group_section
 #define ppcboot_bfd_discard_group bfd_generic_discard_group
index 664a62874be00c0db8e088b0579a3e5d9ab08b52..f83dac2782a1e6782cdc73dd91fe3c949e311812 100644 (file)
@@ -6042,6 +6042,30 @@ bfd_generic_gc_sections (bfd *abfd ATTRIBUTE_UNUSED,
   return TRUE;
 }
 
+/*
+INTERNAL_FUNCTION
+       bfd_generic_lookup_section_flags
+
+SYNOPSIS
+       void bfd_generic_lookup_section_flags
+         (struct bfd_link_info *, struct flag_info *);
+
+DESCRIPTION
+       Provides default handling for section flags lookup
+       -- i.e., does nothing.
+*/
+
+void
+bfd_generic_lookup_section_flags (struct bfd_link_info *info ATTRIBUTE_UNUSED,
+                                 struct flag_info *finfo) 
+{
+  if (finfo != NULL)
+    {
+      (*_bfd_error_handler) (_("INPUT_SECTION_FLAGS are not supported.\n"));
+      return;
+    }
+}
+
 /*
 INTERNAL_FUNCTION
        bfd_generic_merge_sections
index 3cd7e658e795629e49d0c0de419b6afb8fbb3550..7c1f75048318f5df7b99e4ae829365a1c150f4f7 100644 (file)
@@ -516,6 +516,9 @@ CODE_FRAGMENT
 .  {* The BFD which owns the section.  *}
 .  bfd *owner;
 .
+.  {* INPUT_SECTION_FLAGS if specified in the linker script.  *}
+.  struct flag_info *section_flag_info;
+.
 .  {* A symbol which points at this section only.  *}
 .  struct bfd_symbol *symbol;
 .  struct bfd_symbol **symbol_ptr_ptr;
@@ -694,6 +697,9 @@ CODE_FRAGMENT
 .  {* target_index, used_by_bfd, constructor_chain, owner,          *} \
 .     0,            NULL,        NULL,              NULL,              \
 .                                                                      \
+.  {* flag_info,                                                   *}  \
+.     NULL,                                                            \
+.                                                                      \
 .  {* symbol,                    symbol_ptr_ptr,                    *} \
 .     (struct bfd_symbol *) SYM, &SEC.symbol,                          \
 .                                                                      \
index a642231a8f9e8c307b1330524bfd7aef6a506eee..0726f842e3fc0431bd95fa062adedb99aeeb400c 100644 (file)
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -6741,6 +6741,7 @@ som_bfd_link_split_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
   _bfd_generic_copy_link_hash_symbol_type
 #define som_bfd_final_link                      _bfd_generic_final_link
 #define som_bfd_gc_sections                    bfd_generic_gc_sections
+#define som_bfd_lookup_section_flags            bfd_generic_lookup_section_flags
 #define som_bfd_merge_sections                 bfd_generic_merge_sections
 #define som_bfd_is_group_section               bfd_generic_is_group_section
 #define som_bfd_discard_group                  bfd_generic_discard_group
index 6d4de1af7232d29a03e1a714de67747566fc3f43..6226773387252b3d4e9f5df43e832e5a937e9161 100644 (file)
@@ -1252,6 +1252,7 @@ srec_print_symbol (bfd *abfd,
 #define srec_bfd_get_relocated_section_contents   bfd_generic_get_relocated_section_contents
 #define srec_bfd_relax_section                    bfd_generic_relax_section
 #define srec_bfd_gc_sections                      bfd_generic_gc_sections
+#define srec_bfd_lookup_section_flags             bfd_generic_lookup_section_flags
 #define srec_bfd_merge_sections                   bfd_generic_merge_sections
 #define srec_bfd_is_group_section                 bfd_generic_is_group_section
 #define srec_bfd_discard_group                    bfd_generic_discard_group
index ac978a14fbdc98d95e9d9a9a095953b92d60ad42..241ff9c7a25108096bb9930ee48cef366c4e8747 100644 (file)
@@ -178,6 +178,9 @@ DESCRIPTION
 .typedef struct bfd_link_info _bfd_link_info;
 .struct already_linked;
 .
+.{* Forward declaration.  *}
+.typedef struct flag_info flag_info;
+.
 .typedef struct bfd_target
 .{
 .  {* Identifies the kind of target, e.g., SunOS4, Ultrix, etc.  *}
@@ -449,6 +452,7 @@ BFD_JUMP_TABLE macros.
 .  NAME##_bfd_final_link, \
 .  NAME##_bfd_link_split_section, \
 .  NAME##_bfd_gc_sections, \
+.  NAME##_bfd_lookup_section_flags, \
 .  NAME##_bfd_merge_sections, \
 .  NAME##_bfd_is_group_section, \
 .  NAME##_bfd_discard_group, \
@@ -493,6 +497,10 @@ BFD_JUMP_TABLE macros.
 .  {* Remove sections that are not referenced from the output.  *}
 .  bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *);
 .
+.  {* Sets the bitmask of allowed and disallowed section flags.  *}
+.  void (*_bfd_lookup_section_flags) (struct bfd_link_info *,
+.                                    struct flag_info *);
+.
 .  {* Attempt to merge SEC_MERGE sections.  *}
 .  bfd_boolean (*_bfd_merge_sections) (bfd *, struct bfd_link_info *);
 .
index 376569af84bd3a8f43201b1f3187a20fa947a4ad..0ed7b5032b8283973eecf01049de044ced4a79cf 100644 (file)
@@ -943,6 +943,7 @@ tekhex_print_symbol (bfd *abfd,
 #define tekhex_bfd_get_relocated_section_contents   bfd_generic_get_relocated_section_contents
 #define tekhex_bfd_relax_section                    bfd_generic_relax_section
 #define tekhex_bfd_gc_sections                      bfd_generic_gc_sections
+#define tekhex_bfd_lookup_section_flags                    bfd_generic_lookup_section_flags
 #define tekhex_bfd_merge_sections                   bfd_generic_merge_sections
 #define tekhex_bfd_is_group_section                 bfd_generic_is_group_section
 #define tekhex_bfd_discard_group                    bfd_generic_discard_group
index 84a816b69db440bd704f7466bc305e9ba6b1b859..7f7766a52572e48b963e2a3c68a03abb22e465e4 100644 (file)
@@ -806,6 +806,7 @@ versados_canonicalize_reloc (bfd *abfd,
 #define versados_bfd_get_relocated_section_contents   bfd_generic_get_relocated_section_contents
 #define versados_bfd_relax_section                    bfd_generic_relax_section
 #define versados_bfd_gc_sections                      bfd_generic_gc_sections
+#define versados_bfd_lookup_section_flags             bfd_generic_lookup_section_flags
 #define versados_bfd_merge_sections                   bfd_generic_merge_sections
 #define versados_bfd_is_group_section                 bfd_generic_is_group_section
 #define versados_bfd_discard_group                    bfd_generic_discard_group
index 87e35edf7ae98ca36eb7e6a591bd8127295ec831..31dc1fb6153d6e3b10aca31a1c7333b75150f46b 100644 (file)
@@ -9336,6 +9336,7 @@ bfd_vms_get_data (bfd *abfd)
 
 #define alpha_vms_bfd_relax_section bfd_generic_relax_section
 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections
+#define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags
 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections
 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section
 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
index a0900f1fda08176b7ace71b0a4325ce84dad6ba3..01434e1b72d08c7740253b157c8bfa589849a5c0 100644 (file)
@@ -42,6 +42,7 @@
 #define bfd_sym_bfd_get_relocated_section_contents  bfd_generic_get_relocated_section_contents
 #define bfd_sym_bfd_relax_section                   bfd_generic_relax_section
 #define bfd_sym_bfd_gc_sections                     bfd_generic_gc_sections
+#define bfd_sym_bfd_lookup_section_flags            bfd_generic_lookup_section_flags
 #define bfd_sym_bfd_merge_sections                  bfd_generic_merge_sections
 #define bfd_sym_bfd_is_group_section                bfd_generic_is_group_section
 #define bfd_sym_bfd_discard_group                   bfd_generic_discard_group
index bf2c020fdaefafae562f1ebb8ea2444e33a0909d..2a62d3f579b79cf92677799af10b20f83b1091e9 100644 (file)
@@ -1,3 +1,9 @@
+2011-07-11  Catherine Moore  <clm@codesourcery.com>
+
+       * bfdlink.h (flag_type): New enumeration.
+       (flag_info_list): New structure.
+       (flag_info): New structure.
+
 2011-07-09  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/12942
index 193b855113004eb4a281262a4217c919a9c1fc6b..0e583be1875404919299cc0158cfa9c1d89f8b69 100644 (file)
@@ -224,6 +224,26 @@ enum report_method
   RM_GENERATE_ERROR
 };
 
+typedef enum {with_flags, without_flags} flag_type;
+
+/* A section flag list.  */
+struct flag_info_list
+{
+  flag_type with; 
+  const char *name;
+  bfd_boolean valid;
+  struct flag_info_list *next;
+};
+
+/* Section flag info.  */
+struct flag_info
+{
+  flagword only_with_flags;
+  flagword not_with_flags;
+  struct flag_info_list *flag_list;
+  bfd_boolean flags_initialized;
+};
+
 struct bfd_elf_dynamic_list;
 
 /* This structure holds all the information needed to communicate
index 688cb9b9d198de6299994287744dd841a30a813e..8e27855be0c92c114c9503581c737c4f6b0349ee 100644 (file)
@@ -166,6 +166,10 @@ END_RELOC_NUMBERS (R_PPC_max)
 #define        EF_PPC_RELOCATABLE      0x00010000      /* PowerPC -mrelocatable flag.  */
 #define        EF_PPC_RELOCATABLE_LIB  0x00008000      /* PowerPC -mrelocatable-lib flag.  */
 
+/* This bit is reserved by BFD for processor specific stuff.  Name
+   it properly so that we can easily stay consistent elsewhere.  */
+#define SEC_PPC_VLE            SEC_TIC54X_BLOCK
+
 /* Processor specific section headers, sh_type field.  */
 
 #define SHT_ORDERED            SHT_HIPROC      /* Link editor is to sort the \
index 7ce5d7abd6a321f86e4b7163c7399174ac6697a1..fbbb5bdc23daa299166ac79d8a56e031795e2ce8 100644 (file)
@@ -1,3 +1,25 @@
+2011-07-11  Catherine Moore  <clm@codesourcery.com>
+
+       * ld.h (section_flag_list): Add field to struct wildcard_spec.
+       * ld.texinfo (INPUT_SECTION_FLAGS): Document.
+       * ldgram.y (flag_info_list, flag_info): Add to union.
+       (INPUT_SECTION_FLAGS): New token.
+       (wildcard_spec): Initialize section_flag_list to NULL for
+       each alternative.
+       (sect_flag_list, sect_flags): New rules.
+       (input_section_spec_no_keep): Add alternatives to recognize
+       sect_flags.
+       * ldlang.c (walk_wild_consider_section): Initialize
+       section_flag_info field of the section struct.
+       (lang_add_section): Check input section flags.
+       (lang_add_wild): Initialize section_flag_list field of 
+       the statement struct.
+       * ldlang.h (lang_input_statement_struct): Add section_flag_list field.
+       (lang_wild_statement_struct): Likewise.
+       * ldlex.l (INPUT_SECTION_FLAGS): New token.
+       * mri.c (mri_draw_tree): Initialize section_flag_list to NULL.
+       * NEWS: Announce INPUT_SECTION_FLAGS enhancement.
+
 2011-07-09  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/12942
diff --git a/ld/NEWS b/ld/NEWS
index 40a6b9fd82f841bacbc3c9b73e706e833fbc5723..e3fa540385973b378cc3d407ff517ab4c409ae0a 100644 (file)
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,5 +1,8 @@
 -*- text -*-
 
+* INPUT_SECTION_FLAGS has been added to the linker script language
+to allow selection of input sections by section header section flags.
+
 * Add support for the Tilera TILEPRO and TILE-Gx architectures.
 
 * Added SORT_BY_INIT_PRIORITY to the linker script language to permit
diff --git a/ld/ld.h b/ld/ld.h
index 9391923b6ce83449530556671787c96d498ffd18..996cdd22b1b322cd72aebd325326f86c249a161c 100644 (file)
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -96,6 +96,7 @@ struct wildcard_spec {
   const char *name;
   struct name_list *exclude_name_list;
   sort_type sorted;
+  struct flag_info *section_flag_list;
 };
 
 struct wildcard_list {
index 5a8e190c247fee77a9378dceea415b75330bca52..4fb649aafda1215df04dbdfc921ff42855ec1261 100644 (file)
@@ -3859,6 +3859,26 @@ needs to be at a particular location in memory.  For example:
 data.o(.data)
 @end smallexample
 
+To refine the sections that are included based on the section flags
+of an input section, INPUT_SECTION_FLAGS may be used.
+
+Here is a simple example for using Section header flags for ELF sections:
+
+@smallexample
+@group
+SECTIONS @{
+  .text : @{ INPUT_SECTION_FLAGS (SHF_MERGE & SHF_STRINGS) *(.text) @}
+  .text2 :  @{ INPUT_SECTION_FLAGS (!SHF_WRITE) *(.text) @}
+@}
+@end group
+@end smallexample
+
+In this example, the output section @samp{.text} will be comprised of any
+input section matching the name *(.text) whose section header flags
+@code{SHF_MERGE} and @code{SHF_STRINGS} are set.  The output section
+@samp{.text2} will be comprised of any input section matching the name *(.text)
+whose section header flag @code{SHF_WRITE} is clear.
+
 You can also specify files within archives by writing a pattern
 matching the archive, a colon, then the pattern matching the file,
 with no whitespace around the colon.
index 3795ffeb8f002d0ced6672613e2a4cae0e9f82a6..36ccb5b28b7256d415db585d61499a7a6e1bc06c 100644 (file)
@@ -72,6 +72,8 @@ static int error_index;
   struct wildcard_spec wildcard;
   struct wildcard_list *wildcard_list;
   struct name_list *name_list;
+  struct flag_info_list *flag_info_list;
+  struct flag_info *flag_info;
   int token;
   union etree_union *etree;
   struct phdr_info
@@ -93,6 +95,8 @@ static int error_index;
 %type <fill> fill_opt fill_exp
 %type <name_list> exclude_name_list
 %type <wildcard_list> file_NAME_list
+%type <flag_info_list> sect_flag_list
+%type <flag_info> sect_flags
 %type <name> memspec_opt casesymlist
 %type <name> memspec_at_opt
 %type <cname> wildcard_name
@@ -150,7 +154,7 @@ static int error_index;
 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
 %token <name> VERS_TAG VERS_IDENTIFIER
 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
-%token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL
+%token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL INPUT_SECTION_FLAGS
 %token EXCLUDE_FILE
 %token CONSTANT
 %type <versyms> vers_defns
@@ -437,60 +441,121 @@ wildcard_spec:
                          $$.name = $1;
                          $$.sorted = none;
                          $$.exclude_name_list = NULL;
+                         $$.section_flag_list = NULL;
                        }
        |       EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
                        {
                          $$.name = $5;
                          $$.sorted = none;
                          $$.exclude_name_list = $3;
+                         $$.section_flag_list = NULL;
                        }
        |       SORT_BY_NAME '(' wildcard_name ')'
                        {
                          $$.name = $3;
                          $$.sorted = by_name;
                          $$.exclude_name_list = NULL;
+                         $$.section_flag_list = NULL;
                        }
        |       SORT_BY_ALIGNMENT '(' wildcard_name ')'
                        {
                          $$.name = $3;
                          $$.sorted = by_alignment;
                          $$.exclude_name_list = NULL;
+                         $$.section_flag_list = NULL;
                        }
        |       SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
                        {
                          $$.name = $5;
                          $$.sorted = by_name_alignment;
                          $$.exclude_name_list = NULL;
+                         $$.section_flag_list = NULL;
                        }
        |       SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_name ')' ')'
                        {
                          $$.name = $5;
                          $$.sorted = by_name;
                          $$.exclude_name_list = NULL;
+                         $$.section_flag_list = NULL;
                        }
        |       SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_name ')' ')'
                        {
                          $$.name = $5;
                          $$.sorted = by_alignment_name;
                          $$.exclude_name_list = NULL;
+                         $$.section_flag_list = NULL;
                        }
        |       SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
                        {
                          $$.name = $5;
                          $$.sorted = by_alignment;
                          $$.exclude_name_list = NULL;
+                         $$.section_flag_list = NULL;
                        }
        |       SORT_BY_NAME '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')'
                        {
                          $$.name = $7;
                          $$.sorted = by_name;
                          $$.exclude_name_list = $5;
+                         $$.section_flag_list = NULL;
                        }
        |       SORT_BY_INIT_PRIORITY '(' wildcard_name ')'
                        {
                          $$.name = $3;
                          $$.sorted = by_init_priority;
                          $$.exclude_name_list = NULL;
+                         $$.section_flag_list = NULL;
+                       }
+       ;
+
+sect_flag_list:        NAME
+                       {
+                         struct flag_info_list *n;
+                         n = ((struct flag_info_list *) xmalloc (sizeof *n));
+                         if ($1[0] == '!')
+                           {
+                             n->with = without_flags;
+                             n->name = &$1[1];
+                           }
+                         else
+                           {
+                             n->with = with_flags;
+                             n->name = $1;
+                           }
+                         n->valid = FALSE;
+                         n->next = NULL;
+                         $$ = n;
+                       }
+       |       sect_flag_list '&' NAME
+                       {
+                         struct flag_info_list *n;
+                         n = ((struct flag_info_list *) xmalloc (sizeof *n));
+                         if ($3[0] == '!')
+                           {
+                             n->with = without_flags;
+                             n->name = &$3[1];
+                           }
+                         else
+                           {
+                             n->with = with_flags;
+                             n->name = $3;
+                           }
+                         n->valid = FALSE;
+                         n->next = $1;
+                         $$ = n;
+                       }
+       ;
+
+sect_flags:
+               INPUT_SECTION_FLAGS '(' sect_flag_list ')'
+                       {
+                         struct flag_info *n;
+                         n = ((struct flag_info *) xmalloc (sizeof *n));
+                         n->flag_list = $3;
+                         n->flags_initialized = FALSE;
+                         n->not_with_flags = 0;
+                         n->only_with_flags = 0;
+                         $$ = n;
                        }
        ;
 
@@ -541,16 +606,40 @@ input_section_spec_no_keep:
                          tmp.name = $1;
                          tmp.exclude_name_list = NULL;
                          tmp.sorted = none;
+                         tmp.section_flag_list = NULL;
+                         lang_add_wild (&tmp, NULL, ldgram_had_keep);
+                       }
+       |       sect_flags NAME
+                       {
+                         struct wildcard_spec tmp;
+                         tmp.name = $2;
+                         tmp.exclude_name_list = NULL;
+                         tmp.sorted = none;
+                         tmp.section_flag_list = $1;
                          lang_add_wild (&tmp, NULL, ldgram_had_keep);
                        }
         |      '[' file_NAME_list ']'
                        {
                          lang_add_wild (NULL, $2, ldgram_had_keep);
                        }
+        |      sect_flags '[' file_NAME_list ']'
+                       {
+                         struct wildcard_spec tmp;
+                         tmp.name = NULL;
+                         tmp.exclude_name_list = NULL;
+                         tmp.sorted = none;
+                         tmp.section_flag_list = $1;
+                         lang_add_wild (NULL, $3, ldgram_had_keep);
+                       }
        |       wildcard_spec '(' file_NAME_list ')'
                        {
                          lang_add_wild (&$1, $3, ldgram_had_keep);
                        }
+       |       sect_flags wildcard_spec '(' file_NAME_list ')'
+                       {
+                         $2.section_flag_list = $1;
+                         lang_add_wild (&$2, $4, ldgram_had_keep);
+                       }
        ;
 
 input_section_spec:
index 860ce27b3005f9ed943b8cb3b9ad33fa034d3878..3e63eedd409a9bf2fc0865a18626533922d118e2 100644 (file)
@@ -237,6 +237,9 @@ walk_wild_consider_section (lang_wild_statement_type *ptr,
 {
   struct name_list *list_tmp;
 
+  /* Propagate the section_flag_info from the wild statement to the section.  */
+  s->section_flag_info = ptr->section_flag_list;
+
   /* Don't process sections from files which were excluded.  */
   for (list_tmp = sec->spec.exclude_name_list;
        list_tmp;
@@ -2261,8 +2264,11 @@ lang_add_section (lang_statement_list_type *ptr,
                  lang_output_section_statement_type *output)
 {
   flagword flags = section->flags;
+  struct flag_info *sflag_info = section->section_flag_info;
+
   bfd_boolean discard;
   lang_input_section_type *new_section;
+  bfd *abfd = link_info.output_bfd;
 
   /* Discard sections marked with SEC_EXCLUDE.  */
   discard = (flags & SEC_EXCLUDE) != 0;
@@ -2288,6 +2294,28 @@ lang_add_section (lang_statement_list_type *ptr,
       return;
     }
 
+  if (sflag_info)
+    {
+      if (sflag_info->flags_initialized == FALSE)
+       bfd_lookup_section_flags (&link_info, sflag_info);
+
+      if (sflag_info->only_with_flags != 0
+         && sflag_info->not_with_flags != 0
+          && ((sflag_info->not_with_flags & flags) != 0
+              || (sflag_info->only_with_flags & flags)
+                   != sflag_info->only_with_flags))
+       return;
+
+      if (sflag_info->only_with_flags != 0
+         && (sflag_info->only_with_flags & flags)
+              != sflag_info->only_with_flags)
+       return;
+
+      if (sflag_info->not_with_flags != 0
+          && (sflag_info->not_with_flags & flags) != 0)
+       return;
+    }
+
   if (section->output_section != NULL)
     return;
 
@@ -6719,10 +6747,12 @@ lang_add_wild (struct wildcard_spec *filespec,
   new_stmt = new_stat (lang_wild_statement, stat_ptr);
   new_stmt->filename = NULL;
   new_stmt->filenames_sorted = FALSE;
+  new_stmt->section_flag_list = NULL;
   if (filespec != NULL)
     {
       new_stmt->filename = filespec->name;
       new_stmt->filenames_sorted = filespec->sorted == by_name;
+      new_stmt->section_flag_list = filespec->section_flag_list;
     }
   new_stmt->section_list = section_list;
   new_stmt->keep_sections = keep_sections;
index d172c34f9c240ec953ef8000eb1a87a696d677e4..a6d22ce30455207056f0edbc044d85b9422bb3c0 100644 (file)
@@ -240,6 +240,8 @@ typedef struct lang_input_statement_struct
 
   bfd *the_bfd;
 
+  struct flag_info *section_flag_list;
+
   /* Point to the next file - whatever it is, wanders up and down
      archives */
   union lang_statement_union *next;
@@ -337,6 +339,7 @@ struct lang_wild_statement_struct
   walk_wild_section_handler_t walk_wild_section_handler;
   struct wildcard_list *handler_data[4];
   lang_section_bst_type *tree;
+  struct flag_info *section_flag_list;
 };
 
 typedef struct lang_address_statement_struct
index 013c07e473afa49044779c0aeee34809152eb499..4e859b03327ec105235e395b132940edd5282d51 100644 (file)
@@ -313,6 +313,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
 <BOTH,SCRIPT>"org"                     { RTOKEN(ORIGIN);}
 <BOTH,SCRIPT>"l"                       { RTOKEN( LENGTH);}
 <BOTH,SCRIPT>"len"                     { RTOKEN( LENGTH);}
+<EXPRESSION,BOTH,SCRIPT>"INPUT_SECTION_FLAGS"  { RTOKEN(INPUT_SECTION_FLAGS); }
 <EXPRESSION,BOTH,SCRIPT>"INCLUDE"      { RTOKEN(INCLUDE);}
 <BOTH,SCRIPT>"PHDRS"                   { RTOKEN (PHDRS); }
 <EXPRESSION,BOTH,SCRIPT>"AT"           { RTOKEN(AT);}
index ce1406af339e86af5ba2e782651bf758fdfb8d22..91b40dc779e6f64fa8d4d60051464ebc90a1d5fb 100644 (file)
--- a/ld/mri.c
+++ b/ld/mri.c
@@ -215,6 +215,7 @@ mri_draw_tree (void)
          tmp->spec.name = p->name;
          tmp->spec.exclude_name_list = NULL;
          tmp->spec.sorted = none;
+         tmp->spec.section_flag_list = NULL;
          lang_add_wild (NULL, tmp, FALSE);
 
          /* If there is an alias for this section, add it too.  */
@@ -226,6 +227,7 @@ mri_draw_tree (void)
                tmp->spec.name = aptr->name;
                tmp->spec.exclude_name_list = NULL;
                tmp->spec.sorted = none;
+               tmp->spec.section_flag_list = NULL;
                lang_add_wild (NULL, tmp, FALSE);
              }
 
index 4fe8d0c482061954b27f2ddc98ee2291260ec9e8..64c2d10124c4fe6c23e5588dbaac382b39149332 100644 (file)
@@ -1,3 +1,11 @@
+2011-07-11 Catherine Moore  <clm@cm00re.com>
+
+       * ld-scripts/section-flags-1.s: New.
+       * ld-scripts/section-flags-1.t: New.
+       * ld-scripts/section-flags-2.s: New.
+       * ld-scripts/section-flags-2.t: New.
+       * ld-scripts/section-flags.exp: New.
+
 2011-07-11  Alan Modra  <amodra@gmail.com>
 
        * ld-powerpc/tocopt2.s, * ld-powerpc/tocopt2.out,
diff --git a/ld/testsuite/ld-scripts/section-flags-1.s b/ld/testsuite/ld-scripts/section-flags-1.s
new file mode 100644 (file)
index 0000000..566e3c6
--- /dev/null
@@ -0,0 +1,2 @@
+       .text
+       .space 16
diff --git a/ld/testsuite/ld-scripts/section-flags-1.t b/ld/testsuite/ld-scripts/section-flags-1.t
new file mode 100644 (file)
index 0000000..3380489
--- /dev/null
@@ -0,0 +1,21 @@
+MEMORY
+{
+  ram (rwx) : ORIGIN = 0x100000, LENGTH = 144M
+}
+
+SECTIONS
+{
+  .text :
+  {
+    INPUT_SECTION_FLAGS (!SHF_TLS) *(.text .text.* .text_* .gnu.linkonce.t.*)
+  } >ram
+
+  .text_vle : 
+  {
+    INPUT_SECTION_FLAGS (SHF_MERGE & SHF_STRINGS & SHF_LINK_ORDER) *(.text .text.* .text_* .gnu.linkonce.t.*)
+  } >ram
+  .text_other :
+  {
+    INPUT_SECTION_FLAGS (SHF_MERGE & !SHF_STRINGS) *(.text .text.* .text_* .gnu.linkonce.t.*)
+  }
+}
diff --git a/ld/testsuite/ld-scripts/section-flags-2.s b/ld/testsuite/ld-scripts/section-flags-2.s
new file mode 100644 (file)
index 0000000..566e3c6
--- /dev/null
@@ -0,0 +1,2 @@
+       .text
+       .space 16
diff --git a/ld/testsuite/ld-scripts/section-flags-2.t b/ld/testsuite/ld-scripts/section-flags-2.t
new file mode 100644 (file)
index 0000000..ca5ae63
--- /dev/null
@@ -0,0 +1,12 @@
+MEMORY
+{
+  ram (rwx) : ORIGIN = 0x100000, LENGTH = 144M
+}
+
+SECTIONS
+{
+  .text :
+  {
+    INPUT_SECTION_FLAGS (!SHF_TLS) *(EXCLUDE_FILE (section-flags-1.o) .text .text.* .text_* .gnu.linkonce.t.*)
+  } >ram
+}
diff --git a/ld/testsuite/ld-scripts/section-flags.exp b/ld/testsuite/ld-scripts/section-flags.exp
new file mode 100644 (file)
index 0000000..700c3d3
--- /dev/null
@@ -0,0 +1,52 @@
+# Test SECTION_FLAGS in a linker script.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+set testname "SECTION_FLAGS-1"
+
+
+# This test only works for ELF targets
+if {! [is_elf_format]} {
+    unsupported $testname
+    return
+}
+
+if ![ld_assemble $as $srcdir/$subdir/section-flags-1.s tmpdir/section-flags-1.o] {
+    unresolved $testname
+    return
+}
+
+if ![ld_simple_link $ld tmpdir/section-flags-1 "-T $srcdir/$subdir/section-flags-1.t tmpdir/section-flags-1.o"] {
+    fail $testname
+    return
+}
+
+pass $testname
+
+set testname "SECTION_FLAGS-2"
+if ![ld_assemble $as $srcdir/$subdir/section-flags-2.s tmpdir/section-flags-2.o] {
+    unresolved $testname
+    return
+}
+
+if ![ld_simple_link $ld tmpdir/section-flags-2 "-T $srcdir/$subdir/section-flags-2.t tmpdir/section-flags-1.o tmpdir/section-flags-2.o"] {
+    fail $testname
+    return
+}
+
+pass $testname