From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14167 invoked by alias); 30 Jun 2011 21:11:01 -0000 Received: (qmail 14150 invoked by uid 22791); 30 Jun 2011 21:10:56 -0000 X-SWARE-Spam-Status: No, hits=0.1 required=5.0 tests=AWL,BAYES_50,TW_FX,TW_TM,TW_XL,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 30 Jun 2011 21:10:37 +0000 Received: (qmail 32610 invoked from network); 30 Jun 2011 21:10:35 -0000 Received: from unknown (HELO ?10.0.2.15?) (clm@127.0.0.2) by mail.codesourcery.com with ESMTPA; 30 Jun 2011 21:10:35 -0000 Message-ID: <4E0CE648.2080105@codesourcery.com> Date: Thu, 30 Jun 2011 21:11:00 -0000 From: Catherine Moore User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: Nick Clifton CC: binutils@sourceware.org, Tristan Gingold , catherine Moore Subject: Re: PING Re: [RFA] Linker script extension SECTION_FLAGS References: <4DD41EB0.6040300@codesourcery.com> <4DDC37D2.3030700@codesourcery.com> <4DED4E64.6080507@codesourcery.com> <4DEE2390.2030309@redhat.com> <4E025F3A.6020003@codesourcery.com> <4E09BCFF.2030208@redhat.com> In-Reply-To: <4E09BCFF.2030208@redhat.com> Content-Type: multipart/mixed; boundary="------------070204020402050502060800" Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-06/txt/msg00390.txt.bz2 This is a multi-part message in MIME format. --------------070204020402050502060800 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1513 Hi Nick, On 06/28/2011 07:37 AM, Nick Clifton wrote: > Hi Catherine, > > I like this patch, but I am afraid that I cannot approve it yet. There > are still several problems that need to be addressed: > > * You did not test building a toolchain configured with > "--enable-targets=all --enable-64-bit-bfd". There were several targets > that did not build because they did not define an appropriate > xxx_bfd_lookup_section_flags macro. > This has now been done. > > * The new linker tests fail for targets that do not support the > INPUT_SECTION_FLAGS feature. (Ie the ones that use > bfd_generic_lookup_section_flags). > These tests have now been marked as unsupported for platforms other than elf. > * The ld.patch file contained the new linker tests, so the ld-test.patch > file could not be applied afterwards. > Sorry! > > * The code did not check for contradictory input section flags, eg: > > INPUT_SECTION_FLAGS (SHF_TLS & !SHF_TLS) Now done. Thanks for spotting that. > > > * There was no mention of this new feature in the ld/NEWS file. Now done. > > > * You have not provided a patch for GOLD. I would like to keep the two > linkers in sync, at least as far as features go. I did not implement this piece of the patch, although I might be willing to take it on down the road. It looks like you changed your mind about requiring this. > > > I hope that you will be willing to resolve these issues and submit a > revised patch. The new patch is attached. What do you think? Thanks, Catherin --------------070204020402050502060800 Content-Type: text/plain; name="bfd.cl" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="bfd.cl" Content-length: 1903 2011-06-30 Catherine Moore * bfd-in2.h: Regenerated. * bfd.c (bfd_lookup_section_flags): New definition. * binary.c (binary_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. * 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. * 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. * 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. --------------070204020402050502060800 Content-Type: text/x-patch; name="bfd.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="bfd.patch" Content-length: 14550 Index: aout-adobe.c =================================================================== RCS file: /cvs/src/src/bfd/aout-adobe.c,v retrieving revision 1.33 diff -r1.33 aout-adobe.c 461a462 > #define aout_32_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: aout-target.h =================================================================== RCS file: /cvs/src/src/bfd/aout-target.h,v retrieving revision 1.42 diff -r1.42 aout-target.h 488a489,491 > #ifndef MY_bfd_lookup_section_flags > #define MY_bfd_lookup_section_flags bfd_generic_lookup_section_flags > #endif Index: aout-tic30.c =================================================================== RCS file: /cvs/src/src/bfd/aout-tic30.c,v retrieving revision 1.42 diff -r1.42 aout-tic30.c 946a947,949 > #ifndef MY_bfd_lookup_section_flags > #define MY_bfd_lookup_section_flags bfd_generic_lookup_section_flags > #endif Index: bfd-in2.h =================================================================== RCS file: /cvs/src/src/bfd/bfd-in2.h,v retrieving revision 1.540 diff -r1.540 bfd-in2.h 1516a1517,1519 > /* INPUT_SECTION_FLAGS if specified in the linker script. */ > struct flag_info *section_flag_info; > 1694a1698,1700 > /* flag_info, */ \ > NULL, \ > \ 5573a5580,5582 > #define bfd_lookup_section_flags(link_info, flag_info) \ > BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info)) > 5729a5739,5741 > /* Forward declaration. */ > typedef struct flag_info flag_info; > 5998a6011 > NAME##_bfd_lookup_section_flags, \ 6042a6056,6059 > /* Sets the bitmask of allowed and disallowed section flags. */ > void (*_bfd_lookup_section_flags) (struct bfd_link_info *, > struct flag_info *); > Index: bfd.c =================================================================== RCS file: /cvs/src/src/bfd/bfd.c,v retrieving revision 1.117 diff -r1.117 bfd.c 1376a1377,1379 > .#define bfd_lookup_section_flags(link_info, flag_info) \ > . BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info)) > . Index: binary.c =================================================================== RCS file: /cvs/src/src/bfd/binary.c,v retrieving revision 1.40 diff -r1.40 binary.c 301a302 > #define binary_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: bout.c =================================================================== RCS file: /cvs/src/src/bfd/bout.c,v retrieving revision 1.37 diff -r1.37 bout.c 1389a1390 > #define b_out_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: coff-alpha.c =================================================================== RCS file: /cvs/src/src/bfd/coff-alpha.c,v retrieving revision 1.46 diff -r1.46 coff-alpha.c 2395a2396,2398 > /* Input section flag lookup is generic. */ > #define _bfd_ecoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags > Index: coff-mips.c =================================================================== RCS file: /cvs/src/src/bfd/coff-mips.c,v retrieving revision 1.39 diff -r1.39 coff-mips.c 1412a1413,1415 > /* Input section flags is not implemented. */ > #define _bfd_ecoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags > Index: coff-rs6000.c =================================================================== RCS file: /cvs/src/src/bfd/coff-rs6000.c,v retrieving revision 1.102 diff -r1.102 coff-rs6000.c 4104a4105 > bfd_generic_lookup_section_flags, 4358a4360 > bfd_generic_lookup_section_flags, Index: coff64-rs6000.c =================================================================== RCS file: /cvs/src/src/bfd/coff64-rs6000.c,v retrieving revision 1.88 diff -r1.88 coff64-rs6000.c 2740a2741 > bfd_generic_lookup_section_flags, 2996a2998 > bfd_generic_lookup_section_flags, Index: coffcode.h =================================================================== RCS file: /cvs/src/src/bfd/coffcode.h,v retrieving revision 1.179 diff -r1.179 coffcode.h 5654a5655,5658 > #ifndef coff_bfd_lookup_section_flags > #define coff_bfd_lookup_section_flags bfd_generic_lookup_section_flags > #endif > Index: ecoff.c =================================================================== RCS file: /cvs/src/src/bfd/ecoff.c,v retrieving revision 1.73 diff -r1.73 ecoff.c 75a76,77 > /* flag_info, */ > NULL, Index: elf-bfd.h =================================================================== RCS file: /cvs/src/src/bfd/elf-bfd.h,v retrieving revision 1.323 diff -r1.323 elf-bfd.h 1114a1115,1119 > /* This function, if defined, is called to convert target-specific > section flag names into hex values. */ > flagword (*elf_backend_lookup_section_flags_hook) > (char *); > 2195a2201,2203 > extern void bfd_elf_lookup_section_flags > (struct bfd_link_info *, struct flag_info *); > Index: elflink.c =================================================================== RCS file: /cvs/src/src/bfd/elflink.c,v retrieving revision 1.412 diff -r1.412 elflink.c 12169a12170,12246 > /* 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; > } > Index: elfxx-target.h =================================================================== RCS file: /cvs/src/src/bfd/elfxx-target.h,v retrieving revision 1.126 diff -r1.126 elfxx-target.h 176a177,180 > #ifndef bfd_elfNN_bfd_lookup_section_flags > #define bfd_elfNN_bfd_lookup_section_flags bfd_elf_lookup_section_flags > #endif > 531a536,538 > #ifndef elf_backend_lookup_section_flags_hook > #define elf_backend_lookup_section_flags_hook NULL > #endif 719a727 > elf_backend_lookup_section_flags_hook, Index: i386msdos.c =================================================================== RCS file: /cvs/src/src/bfd/i386msdos.c,v retrieving revision 1.31 diff -r1.31 i386msdos.c 145a146 > #define msdos_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: i386os9k.c =================================================================== RCS file: /cvs/src/src/bfd/i386os9k.c,v retrieving revision 1.27 diff -r1.27 i386os9k.c 169a170 > #define os9k_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: ieee.c =================================================================== RCS file: /cvs/src/src/bfd/ieee.c,v retrieving revision 1.71 diff -r1.71 ieee.c 3774a3775 > #define ieee_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: ihex.c =================================================================== RCS file: /cvs/src/src/bfd/ihex.c,v retrieving revision 1.41 diff -r1.41 ihex.c 932a933 > #define ihex_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: libbfd-in.h =================================================================== RCS file: /cvs/src/src/bfd/libbfd-in.h,v retrieving revision 1.88 diff -r1.88 libbfd-in.h 455a456,458 > #define _bfd_nolink_bfd_lookup_section_flags \ > ((void (*) (struct bfd_link_info *, struct flag_info *)) \ > bfd_0) Index: libbfd.h =================================================================== RCS file: /cvs/src/src/bfd/libbfd.h,v retrieving revision 1.253 diff -r1.253 libbfd.h 460a461,463 > #define _bfd_nolink_bfd_lookup_section_flags \ > ((void (*) (struct bfd_link_info *, struct flag_info *)) \ > bfd_0) 2460a2464,2466 > void bfd_generic_lookup_section_flags > (struct bfd_link_info *, struct flag_info *); > Index: mach-o-target.c =================================================================== RCS file: /cvs/src/src/bfd/mach-o-target.c,v retrieving revision 1.17 diff -r1.17 mach-o-target.c 53a54 > #define bfd_mach_o_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: mmo.c =================================================================== RCS file: /cvs/src/src/bfd/mmo.c,v retrieving revision 1.42 diff -r1.42 mmo.c 3192a3193 > #define mmo_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: nlm-target.h =================================================================== RCS file: /cvs/src/src/bfd/nlm-target.h,v retrieving revision 1.23 diff -r1.23 nlm-target.h 47a48 > #define nlm_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: oasys.c =================================================================== RCS file: /cvs/src/src/bfd/oasys.c,v retrieving revision 1.46 diff -r1.46 oasys.c 1198a1199 > #define oasys_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: pef.c =================================================================== RCS file: /cvs/src/src/bfd/pef.c,v retrieving revision 1.32 diff -r1.32 pef.c 50a51 > #define bfd_pef_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: plugin.c =================================================================== RCS file: /cvs/src/src/bfd/plugin.c,v retrieving revision 1.13 diff -r1.13 plugin.c 65a66 > #define bfd_plugin_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: ppcboot.c =================================================================== RCS file: /cvs/src/src/bfd/ppcboot.c,v retrieving revision 1.34 diff -r1.34 ppcboot.c 472a473 > #define ppcboot_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: reloc.c =================================================================== RCS file: /cvs/src/src/bfd/reloc.c,v retrieving revision 1.214 diff -r1.214 reloc.c 6046a6047,6070 > 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 Index: section.c =================================================================== RCS file: /cvs/src/src/bfd/section.c,v retrieving revision 1.110 diff -r1.110 section.c 518a519,521 > . {* INPUT_SECTION_FLAGS if specified in the linker script. *} > . struct flag_info *section_flag_info; > . 696a700,702 > . {* flag_info, *} \ > . NULL, \ > . \ Index: som.c =================================================================== RCS file: /cvs/src/src/bfd/som.c,v retrieving revision 1.84 diff -r1.84 som.c 6743a6744 > #define som_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: srec.c =================================================================== RCS file: /cvs/src/src/bfd/srec.c,v retrieving revision 1.51 diff -r1.51 srec.c 1254a1255 > #define srec_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: targets.c =================================================================== RCS file: /cvs/src/src/bfd/targets.c,v retrieving revision 1.202 diff -r1.202 targets.c 179a180,182 > .{* Forward declaration. *} > .typedef struct flag_info flag_info; > . 450a454 > . NAME##_bfd_lookup_section_flags, \ 494a499,502 > . {* Sets the bitmask of allowed and disallowed section flags. *} > . void (*_bfd_lookup_section_flags) (struct bfd_link_info *, > . struct flag_info *); > . Index: tekhex.c =================================================================== RCS file: /cvs/src/src/bfd/tekhex.c,v retrieving revision 1.40 diff -r1.40 tekhex.c 945a946 > #define tekhex_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: versados.c =================================================================== RCS file: /cvs/src/src/bfd/versados.c,v retrieving revision 1.40 diff -r1.40 versados.c 808a809 > #define versados_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: vms-alpha.c =================================================================== RCS file: /cvs/src/src/bfd/vms-alpha.c,v retrieving revision 1.50 diff -r1.50 vms-alpha.c 9338a9339 > #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags Index: xsym.c =================================================================== RCS file: /cvs/src/src/bfd/xsym.c,v retrieving revision 1.29 diff -r1.29 xsym.c 44a45 > #define bfd_sym_bfd_lookup_section_flags bfd_generic_lookup_section_flags --------------070204020402050502060800 Content-Type: text/plain; name="include.cl" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="include.cl" Content-length: 160 2011-06-30 Catherine Moore * bfdlink.h (flag_type): New enumeration. (flag_info_list): New structure. (flag_info): New structure. --------------070204020402050502060800 Content-Type: text/x-patch; name="include.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="include.patch" Content-length: 805 Index: bfdlink.h =================================================================== RCS file: /cvs/src/src/include/bfdlink.h,v retrieving revision 1.88 diff -u -r1.88 bfdlink.h --- bfdlink.h 20 Jun 2011 13:18:48 -0000 1.88 +++ bfdlink.h 22 Jun 2011 20:40:13 -0000 @@ -224,6 +224,26 @@ 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 --------------070204020402050502060800 Content-Type: text/plain; name="ld.cl" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ld.cl" Content-length: 951 2011-06-30 Catherine Moore * 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. --------------070204020402050502060800 Content-Type: text/x-patch; name="ld.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ld.patch" Content-length: 16256 Index: NEWS =================================================================== RCS file: /cvs/src/src/ld/NEWS,v retrieving revision 1.118 diff -u -r1.118 NEWS --- NEWS 15 Jun 2011 09:12:08 -0000 1.118 +++ NEWS 30 Jun 2011 20:30:03 -0000 @@ -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 Index: ld.h =================================================================== RCS file: /cvs/src/src/ld/ld.h,v retrieving revision 1.50 diff -u -r1.50 ld.h --- ld.h 20 Apr 2011 12:52:16 -0000 1.50 +++ ld.h 30 Jun 2011 20:30:03 -0000 @@ -96,6 +96,7 @@ const char *name; struct name_list *exclude_name_list; sort_type sorted; + struct flag_info *section_flag_list; }; struct wildcard_list { Index: ld.texinfo =================================================================== RCS file: /cvs/src/src/ld/ld.texinfo,v retrieving revision 1.276 diff -u -r1.276 ld.texinfo --- ld.texinfo 20 Jun 2011 13:18:48 -0000 1.276 +++ ld.texinfo 30 Jun 2011 20:30:03 -0000 @@ -3859,6 +3859,26 @@ 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: ldgram.y =================================================================== RCS file: /cvs/src/src/ld/ldgram.y,v retrieving revision 1.65 diff -u -r1.65 ldgram.y --- ldgram.y 13 Jan 2011 13:29:55 -0000 1.65 +++ ldgram.y 30 Jun 2011 20:30:03 -0000 @@ -72,6 +72,8 @@ 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 @@ %type fill_opt fill_exp %type exclude_name_list %type file_NAME_list +%type sect_flag_list +%type sect_flags %type memspec_opt casesymlist %type memspec_at_opt %type wildcard_name @@ -150,7 +154,7 @@ %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START %token 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 vers_defns @@ -437,60 +441,121 @@ $$.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 @@ 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: ldlang.c =================================================================== RCS file: /cvs/src/src/ld/ldlang.c,v retrieving revision 1.372 diff -u -r1.372 ldlang.c --- ldlang.c 13 Jun 2011 00:59:42 -0000 1.372 +++ ldlang.c 30 Jun 2011 20:30:04 -0000 @@ -237,6 +237,9 @@ { 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; @@ -2256,8 +2259,11 @@ 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; @@ -2283,6 +2289,28 @@ 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; @@ -6713,10 +6741,12 @@ 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: ldlang.h =================================================================== RCS file: /cvs/src/src/ld/ldlang.h,v retrieving revision 1.97 diff -u -r1.97 ldlang.h --- ldlang.h 3 May 2011 14:56:14 -0000 1.97 +++ ldlang.h 30 Jun 2011 20:30:04 -0000 @@ -240,6 +240,8 @@ 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 @@ 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: ldlex.l =================================================================== RCS file: /cvs/src/src/ld/ldlex.l,v retrieving revision 1.52 diff -u -r1.52 ldlex.l --- ldlex.l 29 Mar 2011 02:52:36 -0000 1.52 +++ ldlex.l 30 Jun 2011 20:30:04 -0000 @@ -313,6 +313,7 @@ "org" { RTOKEN(ORIGIN);} "l" { RTOKEN( LENGTH);} "len" { RTOKEN( LENGTH);} +"INPUT_SECTION_FLAGS" { RTOKEN(INPUT_SECTION_FLAGS); } "INCLUDE" { RTOKEN(INCLUDE);} "PHDRS" { RTOKEN (PHDRS); } "AT" { RTOKEN(AT);} Index: mri.c =================================================================== RCS file: /cvs/src/src/ld/mri.c,v retrieving revision 1.24 diff -u -r1.24 mri.c --- mri.c 13 Jan 2011 13:06:22 -0000 1.24 +++ mri.c 30 Jun 2011 20:30:04 -0000 @@ -215,6 +215,7 @@ 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 @@ 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: testsuite/ChangeLog =================================================================== RCS file: /cvs/src/src/ld/testsuite/ChangeLog,v retrieving revision 1.1436 diff -u -r1.1436 ChangeLog --- testsuite/ChangeLog 27 Jun 2011 15:02:55 -0000 1.1436 +++ testsuite/ChangeLog 30 Jun 2011 20:30:04 -0000 @@ -1,3 +1,11 @@ +2011-06-30 Catherine Moore + + * 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-06-27 Nick Clifton * ld-elf/elf.exp: Exlcude all v850 targets from note-3 test. Index: testsuite/ld-scripts/section-flags-1.s =================================================================== RCS file: testsuite/ld-scripts/section-flags-1.s diff -N testsuite/ld-scripts/section-flags-1.s --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/ld-scripts/section-flags-1.s 30 Jun 2011 20:30:04 -0000 @@ -0,0 +1,2 @@ + .text + .space 16 Index: testsuite/ld-scripts/section-flags-1.t =================================================================== RCS file: testsuite/ld-scripts/section-flags-1.t diff -N testsuite/ld-scripts/section-flags-1.t --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/ld-scripts/section-flags-1.t 30 Jun 2011 20:30:04 -0000 @@ -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.*) + } +} Index: testsuite/ld-scripts/section-flags-2.s =================================================================== RCS file: testsuite/ld-scripts/section-flags-2.s diff -N testsuite/ld-scripts/section-flags-2.s --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/ld-scripts/section-flags-2.s 30 Jun 2011 20:30:04 -0000 @@ -0,0 +1,2 @@ + .text + .space 16 Index: testsuite/ld-scripts/section-flags-2.t =================================================================== RCS file: testsuite/ld-scripts/section-flags-2.t diff -N testsuite/ld-scripts/section-flags-2.t --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/ld-scripts/section-flags-2.t 30 Jun 2011 20:30:04 -0000 @@ -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 +} Index: testsuite/ld-scripts/section-flags.exp =================================================================== RCS file: testsuite/ld-scripts/section-flags.exp diff -N testsuite/ld-scripts/section-flags.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/ld-scripts/section-flags.exp 30 Jun 2011 20:30:04 -0000 @@ -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 --------------070204020402050502060800--