WIP MachO binutils port assisted by AI I may consider upstreaming this in the future.
0

Configure Feed

Select the types of activity you want to include in your feed.

include/ChangeLog 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.

Catherine Moore (Jul 11, 2011, 3:03 PM UTC) ae17ab41 23ebcd30

+551 -1
+50
bfd/ChangeLog
··· 1 + 2011-07-11 Catherine Moore <clm@codesourcery.com> 2 + 3 + * aout-adobe.c (aout_32_bfd_lookup_section_flags): New definition. 4 + * aout-target.h (MY_bfd_lookup_section_flags): New definition. 5 + * aout-tic30.c (MY_bfd_lookup_section_flags): New definition. 6 + * bfd-in2.h: Regenerated. 7 + * bfd.c (bfd_lookup_section_flags): New definition. 8 + * binary.c (binary_bfd_lookup_section_flags): New definition. 9 + * bout.c (b_out_bfd_lookup_section_flags): New definition. 10 + * coff-alpha.c (_bfd_ecoff_bfd_lookup_section_flags): New definition. 11 + * coff-mips.c (_bfd_ecoff_bfd_lookup_section_flags): New definition. 12 + * coff-rs6000.c (rs6000coff_vec): Include 13 + bfd_generic_lookup_section_flags. 14 + (pmac_xcoff_vec): Likewise. 15 + * coffcode.h (coff_bfd_lookup_section_flags): New definition. 16 + * coff64-rs6000.c (rs6000coff64_vec): Include 17 + bfd_generic_lookup_section_flags. 18 + (aix5coff64_vec): Likewise. 19 + * ecoff.c (bfd_debug_section): Initialize flag_info field. 20 + * elf-bfd.h (elf_backend_lookup_section_flags_hook): Declare. 21 + (bfd_elf_lookup_section_flags): Declare. 22 + * elflink.c (bfd_elf_lookup_section_flags): New function. 23 + * elfxx-target.h (bfd_elfNN_bfd_lookup_section_flags): Define. 24 + (elf_backend_lookup_section_flags_hook): Define. 25 + (elf_backend_data): Add elf_backend_lookup_section_flags_hook. 26 + * i386msdos.c (msdos_bfd_lookup_section_flags): New define. 27 + * i386os9k.c (os9k_bfd_lookup_section_flags): New define. 28 + * ieee.c (ieee_bfd_lookup_section_flags): New define. 29 + * ihex.c (ihex_bfd_lookup_section_flags): New define. 30 + * libbfd-in.h (_bfd_nolink_bfd_lookup_section_flags): Declare. 31 + (bfd_generic_lookup_section_flags): Declare. 32 + * libbfd.h: Regenerated. 33 + * mach-o-target.c (bfd_mach_o_bfd_lookup_section_flags): New. 34 + * mmo.c (mmo_bfd_lookup_section_flags): New definition. 35 + * nlm-target.h (nlm_bfd_lookup_section_flags): New definition. 36 + * oasys.c (oasys_bfd_lookup_section_flags): New definition. 37 + * pef.c (bfd_pef_bfd_lookup_section_flags): New definition. 38 + * plugin.c (bfd_plugin_bfd_lookup_section_flags): New definition. 39 + * ppcboot.c (ppcboot_bfd_lookup_section_flags): New definition. 40 + * reloc.c (bfd_generic_lookup_section_flags): New function. 41 + * som.c (som_bfd_lookup_section_flags): New definition. 42 + * srec.c (srec_bfd_lookup_section_flags): New definition. 43 + * targets.c (flag_info): Declare. 44 + (NAME##_bfd_lookup_section_flags): Add to LINK jump table. 45 + (_bfd_lookup_section_flags): New. 46 + * tekhex.c (tekhex_bfd_lookup_section_flags): New definition. 47 + * versados.c (versados_bfd_lookup_section_flags): New definition. 48 + * vms-alpha.c (alpha_vms_bfd_lookup_section_flag): New definition. 49 + * xsym.c (bfd_sym_bfd_lookup_section_flags): New definition. 50 + 1 51 2011-07-11 H.J. Lu <hongjiu.lu@intel.com> 2 52 3 53 PR ld/12978
+1
bfd/aout-adobe.c
··· 459 459 #define aout_32_get_section_contents_in_window _bfd_generic_get_section_contents_in_window 460 460 #define aout_32_bfd_relax_section bfd_generic_relax_section 461 461 #define aout_32_bfd_gc_sections bfd_generic_gc_sections 462 + #define aout_32_bfd_lookup_section_flags bfd_generic_lookup_section_flags 462 463 #define aout_32_bfd_merge_sections bfd_generic_merge_sections 463 464 #define aout_32_bfd_is_group_section bfd_generic_is_group_section 464 465 #define aout_32_bfd_discard_group bfd_generic_discard_group
+3
bfd/aout-target.h
··· 486 486 #ifndef MY_bfd_gc_sections 487 487 #define MY_bfd_gc_sections bfd_generic_gc_sections 488 488 #endif 489 + #ifndef MY_bfd_lookup_section_flags 490 + #define MY_bfd_lookup_section_flags bfd_generic_lookup_section_flags 491 + #endif 489 492 #ifndef MY_bfd_merge_sections 490 493 #define MY_bfd_merge_sections bfd_generic_merge_sections 491 494 #endif
+3
bfd/aout-tic30.c
··· 944 944 #ifndef MY_bfd_gc_sections 945 945 #define MY_bfd_gc_sections bfd_generic_gc_sections 946 946 #endif 947 + #ifndef MY_bfd_lookup_section_flags 948 + #define MY_bfd_lookup_section_flags bfd_generic_lookup_section_flags 949 + #endif 947 950 #ifndef MY_bfd_merge_sections 948 951 #define MY_bfd_merge_sections bfd_generic_merge_sections 949 952 #endif
+17
bfd/bfd-in2.h
··· 1514 1514 /* The BFD which owns the section. */ 1515 1515 bfd *owner; 1516 1516 1517 + /* INPUT_SECTION_FLAGS if specified in the linker script. */ 1518 + struct flag_info *section_flag_info; 1519 + 1517 1520 /* A symbol which points at this section only. */ 1518 1521 struct bfd_symbol *symbol; 1519 1522 struct bfd_symbol **symbol_ptr_ptr; ··· 1691 1694 \ 1692 1695 /* target_index, used_by_bfd, constructor_chain, owner, */ \ 1693 1696 0, NULL, NULL, NULL, \ 1697 + \ 1698 + /* flag_info, */ \ 1699 + NULL, \ 1694 1700 \ 1695 1701 /* symbol, symbol_ptr_ptr, */ \ 1696 1702 (struct bfd_symbol *) SYM, &SEC.symbol, \ ··· 5571 5577 #define bfd_gc_sections(abfd, link_info) \ 5572 5578 BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info)) 5573 5579 5580 + #define bfd_lookup_section_flags(link_info, flag_info) \ 5581 + BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info)) 5582 + 5574 5583 #define bfd_merge_sections(abfd, link_info) \ 5575 5584 BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info)) 5576 5585 ··· 5727 5736 /* Forward declaration. */ 5728 5737 typedef struct bfd_link_info _bfd_link_info; 5729 5738 struct already_linked; 5739 + 5740 + /* Forward declaration. */ 5741 + typedef struct flag_info flag_info; 5730 5742 5731 5743 typedef struct bfd_target 5732 5744 { ··· 5997 6009 NAME##_bfd_final_link, \ 5998 6010 NAME##_bfd_link_split_section, \ 5999 6011 NAME##_bfd_gc_sections, \ 6012 + NAME##_bfd_lookup_section_flags, \ 6000 6013 NAME##_bfd_merge_sections, \ 6001 6014 NAME##_bfd_is_group_section, \ 6002 6015 NAME##_bfd_discard_group, \ ··· 6040 6053 6041 6054 /* Remove sections that are not referenced from the output. */ 6042 6055 bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *); 6056 + 6057 + /* Sets the bitmask of allowed and disallowed section flags. */ 6058 + void (*_bfd_lookup_section_flags) (struct bfd_link_info *, 6059 + struct flag_info *); 6043 6060 6044 6061 /* Attempt to merge SEC_MERGE sections. */ 6045 6062 bfd_boolean (*_bfd_merge_sections) (bfd *, struct bfd_link_info *);
+3
bfd/bfd.c
··· 1374 1374 .#define bfd_gc_sections(abfd, link_info) \ 1375 1375 . BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info)) 1376 1376 . 1377 + .#define bfd_lookup_section_flags(link_info, flag_info) \ 1378 + . BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info)) 1379 + . 1377 1380 .#define bfd_merge_sections(abfd, link_info) \ 1378 1381 . BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info)) 1379 1382 .
+1
bfd/binary.c
··· 299 299 #define binary_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents 300 300 #define binary_bfd_relax_section bfd_generic_relax_section 301 301 #define binary_bfd_gc_sections bfd_generic_gc_sections 302 + #define binary_bfd_lookup_section_flags bfd_generic_lookup_section_flags 302 303 #define binary_bfd_merge_sections bfd_generic_merge_sections 303 304 #define binary_bfd_is_group_section bfd_generic_is_group_section 304 305 #define binary_bfd_discard_group bfd_generic_discard_group
+1
bfd/bout.c
··· 1387 1387 #define b_out_bfd_final_link _bfd_generic_final_link 1388 1388 #define b_out_bfd_link_split_section _bfd_generic_link_split_section 1389 1389 #define b_out_bfd_gc_sections bfd_generic_gc_sections 1390 + #define b_out_bfd_lookup_section_flags bfd_generic_lookup_section_flags 1390 1391 #define b_out_bfd_merge_sections bfd_generic_merge_sections 1391 1392 #define b_out_bfd_is_group_section bfd_generic_is_group_section 1392 1393 #define b_out_bfd_discard_group bfd_generic_discard_group
+3
bfd/coff-alpha.c
··· 2393 2393 #define _bfd_ecoff_get_section_contents_in_window \ 2394 2394 _bfd_generic_get_section_contents_in_window 2395 2395 2396 + /* Input section flag lookup is generic. */ 2397 + #define _bfd_ecoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags 2398 + 2396 2399 /* Relaxing sections is generic. */ 2397 2400 #define _bfd_ecoff_bfd_relax_section bfd_generic_relax_section 2398 2401 #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections
+3
bfd/coff-mips.c
··· 1410 1410 /* GC of sections is not done. */ 1411 1411 #define _bfd_ecoff_bfd_gc_sections bfd_generic_gc_sections 1412 1412 1413 + /* Input section flags is not implemented. */ 1414 + #define _bfd_ecoff_bfd_lookup_section_flags bfd_generic_lookup_section_flags 1415 + 1413 1416 /* Merging of sections is not done. */ 1414 1417 #define _bfd_ecoff_bfd_merge_sections bfd_generic_merge_sections 1415 1418
+2
bfd/coff-rs6000.c
··· 4102 4102 _bfd_xcoff_bfd_final_link, 4103 4103 _bfd_generic_link_split_section, 4104 4104 bfd_generic_gc_sections, 4105 + bfd_generic_lookup_section_flags, 4105 4106 bfd_generic_merge_sections, 4106 4107 bfd_generic_is_group_section, 4107 4108 bfd_generic_discard_group, ··· 4356 4357 _bfd_xcoff_bfd_final_link, 4357 4358 _bfd_generic_link_split_section, 4358 4359 bfd_generic_gc_sections, 4360 + bfd_generic_lookup_section_flags, 4359 4361 bfd_generic_merge_sections, 4360 4362 bfd_generic_is_group_section, 4361 4363 bfd_generic_discard_group,
+2
bfd/coff64-rs6000.c
··· 2738 2738 _bfd_xcoff_bfd_final_link, 2739 2739 _bfd_generic_link_split_section, 2740 2740 bfd_generic_gc_sections, 2741 + bfd_generic_lookup_section_flags, 2741 2742 bfd_generic_merge_sections, 2742 2743 bfd_generic_is_group_section, 2743 2744 bfd_generic_discard_group, ··· 2994 2995 _bfd_xcoff_bfd_final_link, 2995 2996 _bfd_generic_link_split_section, 2996 2997 bfd_generic_gc_sections, 2998 + bfd_generic_lookup_section_flags, 2997 2999 bfd_generic_merge_sections, 2998 3000 bfd_generic_is_group_section, 2999 3001 bfd_generic_discard_group,
+4
bfd/coffcode.h
··· 5652 5652 #define coff_bfd_gc_sections bfd_generic_gc_sections 5653 5653 #endif 5654 5654 5655 + #ifndef coff_bfd_lookup_section_flags 5656 + #define coff_bfd_lookup_section_flags bfd_generic_lookup_section_flags 5657 + #endif 5658 + 5655 5659 #ifndef coff_bfd_merge_sections 5656 5660 #define coff_bfd_merge_sections bfd_generic_merge_sections 5657 5661 #endif
+2
bfd/ecoff.c
··· 73 73 0, NULL, 0, 74 74 /* target_index, used_by_bfd, constructor_chain, owner, */ 75 75 0, NULL, NULL, NULL, 76 + /* flag_info, */ 77 + NULL, 76 78 /* symbol, */ 77 79 NULL, 78 80 /* symbol_ptr_ptr, */
+8
bfd/elf-bfd.h
··· 1112 1112 char *(*elf_backend_write_core_note) 1113 1113 (bfd *abfd, char *buf, int *bufsiz, int note_type, ...); 1114 1114 1115 + /* This function, if defined, is called to convert target-specific 1116 + section flag names into hex values. */ 1117 + flagword (*elf_backend_lookup_section_flags_hook) 1118 + (char *); 1119 + 1115 1120 /* This function returns class of a reloc type. */ 1116 1121 enum elf_reloc_type_class (*elf_backend_reloc_type_class) 1117 1122 (const Elf_Internal_Rela *); ··· 2192 2197 extern bfd_boolean _bfd_elf_is_function_type (unsigned int); 2193 2198 2194 2199 extern int bfd_elf_get_default_section_type (flagword); 2200 + 2201 + extern void bfd_elf_lookup_section_flags 2202 + (struct bfd_link_info *, struct flag_info *); 2195 2203 2196 2204 extern Elf_Internal_Phdr * _bfd_elf_find_segment_containing_section 2197 2205 (bfd * abfd, asection * section);
+77
bfd/elflink.c
··· 12167 12167 return TRUE; 12168 12168 } 12169 12169 12170 + /* Map an ELF section header flag to its corresponding string. */ 12171 + typedef struct 12172 + { 12173 + char *flag_name; 12174 + flagword flag_value; 12175 + } elf_flags_to_name_table; 12176 + 12177 + static elf_flags_to_name_table elf_flags_to_names [] = 12178 + { 12179 + { "SHF_WRITE", SHF_WRITE }, 12180 + { "SHF_ALLOC", SHF_ALLOC }, 12181 + { "SHF_EXECINSTR", SHF_EXECINSTR }, 12182 + { "SHF_MERGE", SHF_MERGE }, 12183 + { "SHF_STRINGS", SHF_STRINGS }, 12184 + { "SHF_INFO_LINK", SHF_INFO_LINK}, 12185 + { "SHF_LINK_ORDER", SHF_LINK_ORDER}, 12186 + { "SHF_OS_NONCONFORMING", SHF_OS_NONCONFORMING}, 12187 + { "SHF_GROUP", SHF_GROUP }, 12188 + { "SHF_TLS", SHF_TLS }, 12189 + { "SHF_MASKOS", SHF_MASKOS }, 12190 + { "SHF_EXCLUDE", SHF_EXCLUDE }, 12191 + }; 12192 + 12193 + void 12194 + bfd_elf_lookup_section_flags (struct bfd_link_info *info, 12195 + struct flag_info *finfo) 12196 + { 12197 + bfd *output_bfd = info->output_bfd; 12198 + const struct elf_backend_data *bed = get_elf_backend_data (output_bfd); 12199 + struct flag_info_list *tf = finfo->flag_list; 12200 + int with_hex = 0; 12201 + int without_hex = 0; 12202 + 12203 + for (tf = finfo->flag_list; tf != NULL; tf = tf->next) 12204 + { 12205 + int i; 12206 + if (bed->elf_backend_lookup_section_flags_hook) 12207 + { 12208 + flagword hexval = 12209 + (*bed->elf_backend_lookup_section_flags_hook) ((char *) tf->name); 12210 + 12211 + if (hexval != 0) 12212 + { 12213 + if (tf->with == with_flags) 12214 + with_hex |= hexval; 12215 + else if (tf->with == without_flags) 12216 + without_hex |= hexval; 12217 + tf->valid = TRUE; 12218 + continue; 12219 + } 12220 + } 12221 + for (i = 0; i < 12; i++) 12222 + { 12223 + if (!strcmp (tf->name, elf_flags_to_names[i].flag_name)) 12224 + { 12225 + if (tf->with == with_flags) 12226 + with_hex |= elf_flags_to_names[i].flag_value; 12227 + else if (tf->with == without_flags) 12228 + without_hex |= elf_flags_to_names[i].flag_value; 12229 + tf->valid = TRUE; 12230 + continue; 12231 + } 12232 + } 12233 + if (tf->valid == FALSE) 12234 + { 12235 + info->callbacks->einfo 12236 + (_("Unrecognized INPUT_SECTION_FLAG %s\n"), tf->name); 12237 + return; 12238 + } 12239 + } 12240 + finfo->flags_initialized = TRUE; 12241 + finfo->only_with_flags |= with_hex; 12242 + finfo->not_with_flags |= without_hex; 12243 + 12244 + return; 12245 + } 12246 + 12170 12247 struct alloc_got_off_arg { 12171 12248 bfd_vma gotoff; 12172 12249 struct bfd_link_info *info;
+8
bfd/elfxx-target.h
··· 174 174 #define bfd_elfNN_bfd_define_common_symbol bfd_generic_define_common_symbol 175 175 #endif 176 176 177 + #ifndef bfd_elfNN_bfd_lookup_section_flags 178 + #define bfd_elfNN_bfd_lookup_section_flags bfd_elf_lookup_section_flags 179 + #endif 180 + 177 181 #ifndef bfd_elfNN_bfd_make_debug_symbol 178 182 #define bfd_elfNN_bfd_make_debug_symbol \ 179 183 ((asymbol * (*) (bfd *, void *, unsigned long)) bfd_nullvoidptr) ··· 529 533 #ifndef elf_backend_write_core_note 530 534 #define elf_backend_write_core_note NULL 531 535 #endif 536 + #ifndef elf_backend_lookup_section_flags_hook 537 + #define elf_backend_lookup_section_flags_hook NULL 538 + #endif 532 539 #ifndef elf_backend_reloc_type_class 533 540 #define elf_backend_reloc_type_class _bfd_elf_reloc_type_class 534 541 #endif ··· 717 724 elf_backend_grok_prstatus, 718 725 elf_backend_grok_psinfo, 719 726 elf_backend_write_core_note, 727 + elf_backend_lookup_section_flags_hook, 720 728 elf_backend_reloc_type_class, 721 729 elf_backend_discard_info, 722 730 elf_backend_ignore_discarded_relocs,
+1
bfd/i386msdos.c
··· 143 143 bfd_generic_get_relocated_section_contents 144 144 #define msdos_bfd_relax_section bfd_generic_relax_section 145 145 #define msdos_bfd_gc_sections bfd_generic_gc_sections 146 + #define msdos_bfd_lookup_section_flags bfd_generic_lookup_section_flags 146 147 #define msdos_bfd_merge_sections bfd_generic_merge_sections 147 148 #define msdos_bfd_is_group_section bfd_generic_is_group_section 148 149 #define msdos_bfd_discard_group bfd_generic_discard_group
+1
bfd/i386os9k.c
··· 167 167 bfd_generic_get_relocated_section_contents 168 168 #define os9k_bfd_relax_section bfd_generic_relax_section 169 169 #define os9k_bfd_gc_sections bfd_generic_gc_sections 170 + #define os9k_bfd_lookup_section_flags bfd_generic_lookup_section_flags 170 171 #define os9k_bfd_merge_sections bfd_generic_merge_sections 171 172 #define os9k_bfd_is_group_section bfd_generic_is_group_section 172 173 #define os9k_bfd_discard_group bfd_generic_discard_group
+1
bfd/ieee.c
··· 3772 3772 bfd_generic_get_relocated_section_contents 3773 3773 #define ieee_bfd_relax_section bfd_generic_relax_section 3774 3774 #define ieee_bfd_gc_sections bfd_generic_gc_sections 3775 + #define ieee_bfd_lookup_section_flags bfd_generic_lookup_section_flags 3775 3776 #define ieee_bfd_merge_sections bfd_generic_merge_sections 3776 3777 #define ieee_bfd_is_group_section bfd_generic_is_group_section 3777 3778 #define ieee_bfd_discard_group bfd_generic_discard_group
+1
bfd/ihex.c
··· 930 930 #define ihex_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents 931 931 #define ihex_bfd_relax_section bfd_generic_relax_section 932 932 #define ihex_bfd_gc_sections bfd_generic_gc_sections 933 + #define ihex_bfd_lookup_section_flags bfd_generic_lookup_section_flags 933 934 #define ihex_bfd_merge_sections bfd_generic_merge_sections 934 935 #define ihex_bfd_is_group_section bfd_generic_is_group_section 935 936 #define ihex_bfd_discard_group bfd_generic_discard_group
+3
bfd/libbfd-in.h
··· 453 453 #define _bfd_nolink_bfd_gc_sections \ 454 454 ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \ 455 455 bfd_false) 456 + #define _bfd_nolink_bfd_lookup_section_flags \ 457 + ((void (*) (struct bfd_link_info *, struct flag_info *)) \ 458 + bfd_0) 456 459 #define _bfd_nolink_bfd_merge_sections \ 457 460 ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \ 458 461 bfd_false)
+6
bfd/libbfd.h
··· 458 458 #define _bfd_nolink_bfd_gc_sections \ 459 459 ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \ 460 460 bfd_false) 461 + #define _bfd_nolink_bfd_lookup_section_flags \ 462 + ((void (*) (struct bfd_link_info *, struct flag_info *)) \ 463 + bfd_0) 461 464 #define _bfd_nolink_bfd_merge_sections \ 462 465 ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \ 463 466 bfd_false) ··· 2468 2471 2469 2472 bfd_boolean bfd_generic_gc_sections 2470 2473 (bfd *, struct bfd_link_info *); 2474 + 2475 + void bfd_generic_lookup_section_flags 2476 + (struct bfd_link_info *, struct flag_info *); 2471 2477 2472 2478 bfd_boolean bfd_generic_merge_sections 2473 2479 (bfd *, struct bfd_link_info *);
+1
bfd/mach-o-target.c
··· 51 51 #define bfd_mach_o_bfd_set_private_flags _bfd_generic_bfd_set_private_flags 52 52 #define bfd_mach_o_get_section_contents _bfd_generic_get_section_contents 53 53 #define bfd_mach_o_bfd_gc_sections bfd_generic_gc_sections 54 + #define bfd_mach_o_bfd_lookup_section_flags bfd_generic_lookup_section_flags 54 55 #define bfd_mach_o_bfd_merge_sections bfd_generic_merge_sections 55 56 #define bfd_mach_o_bfd_is_group_section bfd_generic_is_group_section 56 57 #define bfd_mach_o_bfd_discard_group bfd_generic_discard_group
+1
bfd/mmo.c
··· 3190 3190 #define mmo_bfd_get_relocated_section_contents \ 3191 3191 bfd_generic_get_relocated_section_contents 3192 3192 #define mmo_bfd_gc_sections bfd_generic_gc_sections 3193 + #define mmo_bfd_lookup_section_flags bfd_generic_lookup_section_flags 3193 3194 #define mmo_bfd_link_hash_table_create _bfd_generic_link_hash_table_create 3194 3195 #define mmo_bfd_link_hash_table_free _bfd_generic_link_hash_table_free 3195 3196 #define mmo_bfd_link_add_symbols _bfd_generic_link_add_symbols
+1
bfd/nlm-target.h
··· 45 45 #define nlm_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents 46 46 #define nlm_bfd_relax_section bfd_generic_relax_section 47 47 #define nlm_bfd_gc_sections bfd_generic_gc_sections 48 + #define nlm_bfd_lookup_section_flags bfd_generic_lookup_section_flags 48 49 #define nlm_bfd_merge_sections bfd_generic_merge_sections 49 50 #define nlm_bfd_is_group_section bfd_generic_is_group_section 50 51 #define nlm_bfd_discard_group bfd_generic_discard_group
+1
bfd/oasys.c
··· 1196 1196 #define oasys_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents 1197 1197 #define oasys_bfd_relax_section bfd_generic_relax_section 1198 1198 #define oasys_bfd_gc_sections bfd_generic_gc_sections 1199 + #define oasys_bfd_lookup_section_flags bfd_generic_lookup_section_flags 1199 1200 #define oasys_bfd_merge_sections bfd_generic_merge_sections 1200 1201 #define oasys_bfd_is_group_section bfd_generic_is_group_section 1201 1202 #define oasys_bfd_discard_group bfd_generic_discard_group
+1
bfd/pef.c
··· 48 48 #define bfd_pef_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents 49 49 #define bfd_pef_bfd_relax_section bfd_generic_relax_section 50 50 #define bfd_pef_bfd_gc_sections bfd_generic_gc_sections 51 + #define bfd_pef_bfd_lookup_section_flags bfd_generic_lookup_section_flags 51 52 #define bfd_pef_bfd_merge_sections bfd_generic_merge_sections 52 53 #define bfd_pef_bfd_is_group_section bfd_generic_is_group_section 53 54 #define bfd_pef_bfd_discard_group bfd_generic_discard_group
+1
bfd/plugin.c
··· 63 63 #define bfd_plugin_bfd_final_link _bfd_generic_final_link 64 64 #define bfd_plugin_bfd_link_split_section _bfd_generic_link_split_section 65 65 #define bfd_plugin_bfd_gc_sections bfd_generic_gc_sections 66 + #define bfd_plugin_bfd_lookup_section_flags bfd_generic_lookup_section_flags 66 67 #define bfd_plugin_bfd_merge_sections bfd_generic_merge_sections 67 68 #define bfd_plugin_bfd_is_group_section bfd_generic_is_group_section 68 69 #define bfd_plugin_bfd_discard_group bfd_generic_discard_group
+1
bfd/ppcboot.c
··· 470 470 bfd_generic_get_relocated_section_contents 471 471 #define ppcboot_bfd_relax_section bfd_generic_relax_section 472 472 #define ppcboot_bfd_gc_sections bfd_generic_gc_sections 473 + #define ppcboot_bfd_lookup_section_flags bfd_generic_lookup_section_flags 473 474 #define ppcboot_bfd_merge_sections bfd_generic_merge_sections 474 475 #define ppcboot_bfd_is_group_section bfd_generic_is_group_section 475 476 #define ppcboot_bfd_discard_group bfd_generic_discard_group
+24
bfd/reloc.c
··· 6044 6044 6045 6045 /* 6046 6046 INTERNAL_FUNCTION 6047 + bfd_generic_lookup_section_flags 6048 + 6049 + SYNOPSIS 6050 + void bfd_generic_lookup_section_flags 6051 + (struct bfd_link_info *, struct flag_info *); 6052 + 6053 + DESCRIPTION 6054 + Provides default handling for section flags lookup 6055 + -- i.e., does nothing. 6056 + */ 6057 + 6058 + void 6059 + bfd_generic_lookup_section_flags (struct bfd_link_info *info ATTRIBUTE_UNUSED, 6060 + struct flag_info *finfo) 6061 + { 6062 + if (finfo != NULL) 6063 + { 6064 + (*_bfd_error_handler) (_("INPUT_SECTION_FLAGS are not supported.\n")); 6065 + return; 6066 + } 6067 + } 6068 + 6069 + /* 6070 + INTERNAL_FUNCTION 6047 6071 bfd_generic_merge_sections 6048 6072 6049 6073 SYNOPSIS
+6
bfd/section.c
··· 516 516 . {* The BFD which owns the section. *} 517 517 . bfd *owner; 518 518 . 519 + . {* INPUT_SECTION_FLAGS if specified in the linker script. *} 520 + . struct flag_info *section_flag_info; 521 + . 519 522 . {* A symbol which points at this section only. *} 520 523 . struct bfd_symbol *symbol; 521 524 . struct bfd_symbol **symbol_ptr_ptr; ··· 693 696 . \ 694 697 . {* target_index, used_by_bfd, constructor_chain, owner, *} \ 695 698 . 0, NULL, NULL, NULL, \ 699 + . \ 700 + . {* flag_info, *} \ 701 + . NULL, \ 696 702 . \ 697 703 . {* symbol, symbol_ptr_ptr, *} \ 698 704 . (struct bfd_symbol *) SYM, &SEC.symbol, \
+1
bfd/som.c
··· 6741 6741 _bfd_generic_copy_link_hash_symbol_type 6742 6742 #define som_bfd_final_link _bfd_generic_final_link 6743 6743 #define som_bfd_gc_sections bfd_generic_gc_sections 6744 + #define som_bfd_lookup_section_flags bfd_generic_lookup_section_flags 6744 6745 #define som_bfd_merge_sections bfd_generic_merge_sections 6745 6746 #define som_bfd_is_group_section bfd_generic_is_group_section 6746 6747 #define som_bfd_discard_group bfd_generic_discard_group
+1
bfd/srec.c
··· 1252 1252 #define srec_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents 1253 1253 #define srec_bfd_relax_section bfd_generic_relax_section 1254 1254 #define srec_bfd_gc_sections bfd_generic_gc_sections 1255 + #define srec_bfd_lookup_section_flags bfd_generic_lookup_section_flags 1255 1256 #define srec_bfd_merge_sections bfd_generic_merge_sections 1256 1257 #define srec_bfd_is_group_section bfd_generic_is_group_section 1257 1258 #define srec_bfd_discard_group bfd_generic_discard_group
+8
bfd/targets.c
··· 178 178 .typedef struct bfd_link_info _bfd_link_info; 179 179 .struct already_linked; 180 180 . 181 + .{* Forward declaration. *} 182 + .typedef struct flag_info flag_info; 183 + . 181 184 .typedef struct bfd_target 182 185 .{ 183 186 . {* Identifies the kind of target, e.g., SunOS4, Ultrix, etc. *} ··· 449 452 . NAME##_bfd_final_link, \ 450 453 . NAME##_bfd_link_split_section, \ 451 454 . NAME##_bfd_gc_sections, \ 455 + . NAME##_bfd_lookup_section_flags, \ 452 456 . NAME##_bfd_merge_sections, \ 453 457 . NAME##_bfd_is_group_section, \ 454 458 . NAME##_bfd_discard_group, \ ··· 492 496 . 493 497 . {* Remove sections that are not referenced from the output. *} 494 498 . bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *); 499 + . 500 + . {* Sets the bitmask of allowed and disallowed section flags. *} 501 + . void (*_bfd_lookup_section_flags) (struct bfd_link_info *, 502 + . struct flag_info *); 495 503 . 496 504 . {* Attempt to merge SEC_MERGE sections. *} 497 505 . bfd_boolean (*_bfd_merge_sections) (bfd *, struct bfd_link_info *);
+1
bfd/tekhex.c
··· 943 943 #define tekhex_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents 944 944 #define tekhex_bfd_relax_section bfd_generic_relax_section 945 945 #define tekhex_bfd_gc_sections bfd_generic_gc_sections 946 + #define tekhex_bfd_lookup_section_flags bfd_generic_lookup_section_flags 946 947 #define tekhex_bfd_merge_sections bfd_generic_merge_sections 947 948 #define tekhex_bfd_is_group_section bfd_generic_is_group_section 948 949 #define tekhex_bfd_discard_group bfd_generic_discard_group
+1
bfd/versados.c
··· 806 806 #define versados_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents 807 807 #define versados_bfd_relax_section bfd_generic_relax_section 808 808 #define versados_bfd_gc_sections bfd_generic_gc_sections 809 + #define versados_bfd_lookup_section_flags bfd_generic_lookup_section_flags 809 810 #define versados_bfd_merge_sections bfd_generic_merge_sections 810 811 #define versados_bfd_is_group_section bfd_generic_is_group_section 811 812 #define versados_bfd_discard_group bfd_generic_discard_group
+1
bfd/vms-alpha.c
··· 9336 9336 9337 9337 #define alpha_vms_bfd_relax_section bfd_generic_relax_section 9338 9338 #define alpha_vms_bfd_gc_sections bfd_generic_gc_sections 9339 + #define alpha_vms_bfd_lookup_section_flags bfd_generic_lookup_section_flags 9339 9340 #define alpha_vms_bfd_merge_sections bfd_generic_merge_sections 9340 9341 #define alpha_vms_bfd_is_group_section bfd_generic_is_group_section 9341 9342 #define alpha_vms_bfd_discard_group bfd_generic_discard_group
+1
bfd/xsym.c
··· 42 42 #define bfd_sym_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents 43 43 #define bfd_sym_bfd_relax_section bfd_generic_relax_section 44 44 #define bfd_sym_bfd_gc_sections bfd_generic_gc_sections 45 + #define bfd_sym_bfd_lookup_section_flags bfd_generic_lookup_section_flags 45 46 #define bfd_sym_bfd_merge_sections bfd_generic_merge_sections 46 47 #define bfd_sym_bfd_is_group_section bfd_generic_is_group_section 47 48 #define bfd_sym_bfd_discard_group bfd_generic_discard_group
+6
include/ChangeLog
··· 1 + 2011-07-11 Catherine Moore <clm@codesourcery.com> 2 + 3 + * bfdlink.h (flag_type): New enumeration. 4 + (flag_info_list): New structure. 5 + (flag_info): New structure. 6 + 1 7 2011-07-09 H.J. Lu <hongjiu.lu@intel.com> 2 8 3 9 PR ld/12942
+20
include/bfdlink.h
··· 224 224 RM_GENERATE_ERROR 225 225 }; 226 226 227 + typedef enum {with_flags, without_flags} flag_type; 228 + 229 + /* A section flag list. */ 230 + struct flag_info_list 231 + { 232 + flag_type with; 233 + const char *name; 234 + bfd_boolean valid; 235 + struct flag_info_list *next; 236 + }; 237 + 238 + /* Section flag info. */ 239 + struct flag_info 240 + { 241 + flagword only_with_flags; 242 + flagword not_with_flags; 243 + struct flag_info_list *flag_list; 244 + bfd_boolean flags_initialized; 245 + }; 246 + 227 247 struct bfd_elf_dynamic_list; 228 248 229 249 /* This structure holds all the information needed to communicate
+4
include/elf/ppc.h
··· 166 166 #define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag. */ 167 167 #define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib flag. */ 168 168 169 + /* This bit is reserved by BFD for processor specific stuff. Name 170 + it properly so that we can easily stay consistent elsewhere. */ 171 + #define SEC_PPC_VLE SEC_TIC54X_BLOCK 172 + 169 173 /* Processor specific section headers, sh_type field. */ 170 174 171 175 #define SHT_ORDERED SHT_HIPROC /* Link editor is to sort the \
+22
ld/ChangeLog
··· 1 + 2011-07-11 Catherine Moore <clm@codesourcery.com> 2 + 3 + * ld.h (section_flag_list): Add field to struct wildcard_spec. 4 + * ld.texinfo (INPUT_SECTION_FLAGS): Document. 5 + * ldgram.y (flag_info_list, flag_info): Add to union. 6 + (INPUT_SECTION_FLAGS): New token. 7 + (wildcard_spec): Initialize section_flag_list to NULL for 8 + each alternative. 9 + (sect_flag_list, sect_flags): New rules. 10 + (input_section_spec_no_keep): Add alternatives to recognize 11 + sect_flags. 12 + * ldlang.c (walk_wild_consider_section): Initialize 13 + section_flag_info field of the section struct. 14 + (lang_add_section): Check input section flags. 15 + (lang_add_wild): Initialize section_flag_list field of 16 + the statement struct. 17 + * ldlang.h (lang_input_statement_struct): Add section_flag_list field. 18 + (lang_wild_statement_struct): Likewise. 19 + * ldlex.l (INPUT_SECTION_FLAGS): New token. 20 + * mri.c (mri_draw_tree): Initialize section_flag_list to NULL. 21 + * NEWS: Announce INPUT_SECTION_FLAGS enhancement. 22 + 1 23 2011-07-09 H.J. Lu <hongjiu.lu@intel.com> 2 24 3 25 PR ld/12942
+3
ld/NEWS
··· 1 1 -*- text -*- 2 2 3 + * INPUT_SECTION_FLAGS has been added to the linker script language 4 + to allow selection of input sections by section header section flags. 5 + 3 6 * Add support for the Tilera TILEPRO and TILE-Gx architectures. 4 7 5 8 * Added SORT_BY_INIT_PRIORITY to the linker script language to permit
+1
ld/ld.h
··· 96 96 const char *name; 97 97 struct name_list *exclude_name_list; 98 98 sort_type sorted; 99 + struct flag_info *section_flag_list; 99 100 }; 100 101 101 102 struct wildcard_list {
+20
ld/ld.texinfo
··· 3859 3859 data.o(.data) 3860 3860 @end smallexample 3861 3861 3862 + To refine the sections that are included based on the section flags 3863 + of an input section, INPUT_SECTION_FLAGS may be used. 3864 + 3865 + Here is a simple example for using Section header flags for ELF sections: 3866 + 3867 + @smallexample 3868 + @group 3869 + SECTIONS @{ 3870 + .text : @{ INPUT_SECTION_FLAGS (SHF_MERGE & SHF_STRINGS) *(.text) @} 3871 + .text2 : @{ INPUT_SECTION_FLAGS (!SHF_WRITE) *(.text) @} 3872 + @} 3873 + @end group 3874 + @end smallexample 3875 + 3876 + In this example, the output section @samp{.text} will be comprised of any 3877 + input section matching the name *(.text) whose section header flags 3878 + @code{SHF_MERGE} and @code{SHF_STRINGS} are set. The output section 3879 + @samp{.text2} will be comprised of any input section matching the name *(.text) 3880 + whose section header flag @code{SHF_WRITE} is clear. 3881 + 3862 3882 You can also specify files within archives by writing a pattern 3863 3883 matching the archive, a colon, then the pattern matching the file, 3864 3884 with no whitespace around the colon.
+90 -1
ld/ldgram.y
··· 72 72 struct wildcard_spec wildcard; 73 73 struct wildcard_list *wildcard_list; 74 74 struct name_list *name_list; 75 + struct flag_info_list *flag_info_list; 76 + struct flag_info *flag_info; 75 77 int token; 76 78 union etree_union *etree; 77 79 struct phdr_info ··· 93 95 %type <fill> fill_opt fill_exp 94 96 %type <name_list> exclude_name_list 95 97 %type <wildcard_list> file_NAME_list 98 + %type <flag_info_list> sect_flag_list 99 + %type <flag_info> sect_flags 96 100 %type <name> memspec_opt casesymlist 97 101 %type <name> memspec_at_opt 98 102 %type <cname> wildcard_name ··· 150 154 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START 151 155 %token <name> VERS_TAG VERS_IDENTIFIER 152 156 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT 153 - %token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL 157 + %token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL INPUT_SECTION_FLAGS 154 158 %token EXCLUDE_FILE 155 159 %token CONSTANT 156 160 %type <versyms> vers_defns ··· 437 441 $$.name = $1; 438 442 $$.sorted = none; 439 443 $$.exclude_name_list = NULL; 444 + $$.section_flag_list = NULL; 440 445 } 441 446 | EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name 442 447 { 443 448 $$.name = $5; 444 449 $$.sorted = none; 445 450 $$.exclude_name_list = $3; 451 + $$.section_flag_list = NULL; 446 452 } 447 453 | SORT_BY_NAME '(' wildcard_name ')' 448 454 { 449 455 $$.name = $3; 450 456 $$.sorted = by_name; 451 457 $$.exclude_name_list = NULL; 458 + $$.section_flag_list = NULL; 452 459 } 453 460 | SORT_BY_ALIGNMENT '(' wildcard_name ')' 454 461 { 455 462 $$.name = $3; 456 463 $$.sorted = by_alignment; 457 464 $$.exclude_name_list = NULL; 465 + $$.section_flag_list = NULL; 458 466 } 459 467 | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')' 460 468 { 461 469 $$.name = $5; 462 470 $$.sorted = by_name_alignment; 463 471 $$.exclude_name_list = NULL; 472 + $$.section_flag_list = NULL; 464 473 } 465 474 | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_name ')' ')' 466 475 { 467 476 $$.name = $5; 468 477 $$.sorted = by_name; 469 478 $$.exclude_name_list = NULL; 479 + $$.section_flag_list = NULL; 470 480 } 471 481 | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_name ')' ')' 472 482 { 473 483 $$.name = $5; 474 484 $$.sorted = by_alignment_name; 475 485 $$.exclude_name_list = NULL; 486 + $$.section_flag_list = NULL; 476 487 } 477 488 | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')' 478 489 { 479 490 $$.name = $5; 480 491 $$.sorted = by_alignment; 481 492 $$.exclude_name_list = NULL; 493 + $$.section_flag_list = NULL; 482 494 } 483 495 | SORT_BY_NAME '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')' 484 496 { 485 497 $$.name = $7; 486 498 $$.sorted = by_name; 487 499 $$.exclude_name_list = $5; 500 + $$.section_flag_list = NULL; 488 501 } 489 502 | SORT_BY_INIT_PRIORITY '(' wildcard_name ')' 490 503 { 491 504 $$.name = $3; 492 505 $$.sorted = by_init_priority; 493 506 $$.exclude_name_list = NULL; 507 + $$.section_flag_list = NULL; 508 + } 509 + ; 510 + 511 + sect_flag_list: NAME 512 + { 513 + struct flag_info_list *n; 514 + n = ((struct flag_info_list *) xmalloc (sizeof *n)); 515 + if ($1[0] == '!') 516 + { 517 + n->with = without_flags; 518 + n->name = &$1[1]; 519 + } 520 + else 521 + { 522 + n->with = with_flags; 523 + n->name = $1; 524 + } 525 + n->valid = FALSE; 526 + n->next = NULL; 527 + $$ = n; 528 + } 529 + | sect_flag_list '&' NAME 530 + { 531 + struct flag_info_list *n; 532 + n = ((struct flag_info_list *) xmalloc (sizeof *n)); 533 + if ($3[0] == '!') 534 + { 535 + n->with = without_flags; 536 + n->name = &$3[1]; 537 + } 538 + else 539 + { 540 + n->with = with_flags; 541 + n->name = $3; 542 + } 543 + n->valid = FALSE; 544 + n->next = $1; 545 + $$ = n; 546 + } 547 + ; 548 + 549 + sect_flags: 550 + INPUT_SECTION_FLAGS '(' sect_flag_list ')' 551 + { 552 + struct flag_info *n; 553 + n = ((struct flag_info *) xmalloc (sizeof *n)); 554 + n->flag_list = $3; 555 + n->flags_initialized = FALSE; 556 + n->not_with_flags = 0; 557 + n->only_with_flags = 0; 558 + $$ = n; 494 559 } 495 560 ; 496 561 ··· 541 606 tmp.name = $1; 542 607 tmp.exclude_name_list = NULL; 543 608 tmp.sorted = none; 609 + tmp.section_flag_list = NULL; 610 + lang_add_wild (&tmp, NULL, ldgram_had_keep); 611 + } 612 + | sect_flags NAME 613 + { 614 + struct wildcard_spec tmp; 615 + tmp.name = $2; 616 + tmp.exclude_name_list = NULL; 617 + tmp.sorted = none; 618 + tmp.section_flag_list = $1; 544 619 lang_add_wild (&tmp, NULL, ldgram_had_keep); 545 620 } 546 621 | '[' file_NAME_list ']' 547 622 { 548 623 lang_add_wild (NULL, $2, ldgram_had_keep); 549 624 } 625 + | sect_flags '[' file_NAME_list ']' 626 + { 627 + struct wildcard_spec tmp; 628 + tmp.name = NULL; 629 + tmp.exclude_name_list = NULL; 630 + tmp.sorted = none; 631 + tmp.section_flag_list = $1; 632 + lang_add_wild (NULL, $3, ldgram_had_keep); 633 + } 550 634 | wildcard_spec '(' file_NAME_list ')' 551 635 { 552 636 lang_add_wild (&$1, $3, ldgram_had_keep); 637 + } 638 + | sect_flags wildcard_spec '(' file_NAME_list ')' 639 + { 640 + $2.section_flag_list = $1; 641 + lang_add_wild (&$2, $4, ldgram_had_keep); 553 642 } 554 643 ; 555 644
+30
ld/ldlang.c
··· 237 237 { 238 238 struct name_list *list_tmp; 239 239 240 + /* Propagate the section_flag_info from the wild statement to the section. */ 241 + s->section_flag_info = ptr->section_flag_list; 242 + 240 243 /* Don't process sections from files which were excluded. */ 241 244 for (list_tmp = sec->spec.exclude_name_list; 242 245 list_tmp; ··· 2261 2264 lang_output_section_statement_type *output) 2262 2265 { 2263 2266 flagword flags = section->flags; 2267 + struct flag_info *sflag_info = section->section_flag_info; 2268 + 2264 2269 bfd_boolean discard; 2265 2270 lang_input_section_type *new_section; 2271 + bfd *abfd = link_info.output_bfd; 2266 2272 2267 2273 /* Discard sections marked with SEC_EXCLUDE. */ 2268 2274 discard = (flags & SEC_EXCLUDE) != 0; ··· 2286 2292 section->output_section = bfd_abs_section_ptr; 2287 2293 } 2288 2294 return; 2295 + } 2296 + 2297 + if (sflag_info) 2298 + { 2299 + if (sflag_info->flags_initialized == FALSE) 2300 + bfd_lookup_section_flags (&link_info, sflag_info); 2301 + 2302 + if (sflag_info->only_with_flags != 0 2303 + && sflag_info->not_with_flags != 0 2304 + && ((sflag_info->not_with_flags & flags) != 0 2305 + || (sflag_info->only_with_flags & flags) 2306 + != sflag_info->only_with_flags)) 2307 + return; 2308 + 2309 + if (sflag_info->only_with_flags != 0 2310 + && (sflag_info->only_with_flags & flags) 2311 + != sflag_info->only_with_flags) 2312 + return; 2313 + 2314 + if (sflag_info->not_with_flags != 0 2315 + && (sflag_info->not_with_flags & flags) != 0) 2316 + return; 2289 2317 } 2290 2318 2291 2319 if (section->output_section != NULL) ··· 6719 6747 new_stmt = new_stat (lang_wild_statement, stat_ptr); 6720 6748 new_stmt->filename = NULL; 6721 6749 new_stmt->filenames_sorted = FALSE; 6750 + new_stmt->section_flag_list = NULL; 6722 6751 if (filespec != NULL) 6723 6752 { 6724 6753 new_stmt->filename = filespec->name; 6725 6754 new_stmt->filenames_sorted = filespec->sorted == by_name; 6755 + new_stmt->section_flag_list = filespec->section_flag_list; 6726 6756 } 6727 6757 new_stmt->section_list = section_list; 6728 6758 new_stmt->keep_sections = keep_sections;
+3
ld/ldlang.h
··· 240 240 241 241 bfd *the_bfd; 242 242 243 + struct flag_info *section_flag_list; 244 + 243 245 /* Point to the next file - whatever it is, wanders up and down 244 246 archives */ 245 247 union lang_statement_union *next; ··· 337 339 walk_wild_section_handler_t walk_wild_section_handler; 338 340 struct wildcard_list *handler_data[4]; 339 341 lang_section_bst_type *tree; 342 + struct flag_info *section_flag_list; 340 343 }; 341 344 342 345 typedef struct lang_address_statement_struct
+1
ld/ldlex.l
··· 313 313 <BOTH,SCRIPT>"org" { RTOKEN(ORIGIN);} 314 314 <BOTH,SCRIPT>"l" { RTOKEN( LENGTH);} 315 315 <BOTH,SCRIPT>"len" { RTOKEN( LENGTH);} 316 + <EXPRESSION,BOTH,SCRIPT>"INPUT_SECTION_FLAGS" { RTOKEN(INPUT_SECTION_FLAGS); } 316 317 <EXPRESSION,BOTH,SCRIPT>"INCLUDE" { RTOKEN(INCLUDE);} 317 318 <BOTH,SCRIPT>"PHDRS" { RTOKEN (PHDRS); } 318 319 <EXPRESSION,BOTH,SCRIPT>"AT" { RTOKEN(AT);}
+2
ld/mri.c
··· 215 215 tmp->spec.name = p->name; 216 216 tmp->spec.exclude_name_list = NULL; 217 217 tmp->spec.sorted = none; 218 + tmp->spec.section_flag_list = NULL; 218 219 lang_add_wild (NULL, tmp, FALSE); 219 220 220 221 /* If there is an alias for this section, add it too. */ ··· 226 227 tmp->spec.name = aptr->name; 227 228 tmp->spec.exclude_name_list = NULL; 228 229 tmp->spec.sorted = none; 230 + tmp->spec.section_flag_list = NULL; 229 231 lang_add_wild (NULL, tmp, FALSE); 230 232 } 231 233
+8
ld/testsuite/ChangeLog
··· 1 + 2011-07-11 Catherine Moore <clm@cm00re.com> 2 + 3 + * ld-scripts/section-flags-1.s: New. 4 + * ld-scripts/section-flags-1.t: New. 5 + * ld-scripts/section-flags-2.s: New. 6 + * ld-scripts/section-flags-2.t: New. 7 + * ld-scripts/section-flags.exp: New. 8 + 1 9 2011-07-11 Alan Modra <amodra@gmail.com> 2 10 3 11 * ld-powerpc/tocopt2.s, * ld-powerpc/tocopt2.out,
+2
ld/testsuite/ld-scripts/section-flags-1.s
··· 1 + .text 2 + .space 16
+21
ld/testsuite/ld-scripts/section-flags-1.t
··· 1 + MEMORY 2 + { 3 + ram (rwx) : ORIGIN = 0x100000, LENGTH = 144M 4 + } 5 + 6 + SECTIONS 7 + { 8 + .text : 9 + { 10 + INPUT_SECTION_FLAGS (!SHF_TLS) *(.text .text.* .text_* .gnu.linkonce.t.*) 11 + } >ram 12 + 13 + .text_vle : 14 + { 15 + INPUT_SECTION_FLAGS (SHF_MERGE & SHF_STRINGS & SHF_LINK_ORDER) *(.text .text.* .text_* .gnu.linkonce.t.*) 16 + } >ram 17 + .text_other : 18 + { 19 + INPUT_SECTION_FLAGS (SHF_MERGE & !SHF_STRINGS) *(.text .text.* .text_* .gnu.linkonce.t.*) 20 + } 21 + }
+2
ld/testsuite/ld-scripts/section-flags-2.s
··· 1 + .text 2 + .space 16
+12
ld/testsuite/ld-scripts/section-flags-2.t
··· 1 + MEMORY 2 + { 3 + ram (rwx) : ORIGIN = 0x100000, LENGTH = 144M 4 + } 5 + 6 + SECTIONS 7 + { 8 + .text : 9 + { 10 + INPUT_SECTION_FLAGS (!SHF_TLS) *(EXCLUDE_FILE (section-flags-1.o) .text .text.* .text_* .gnu.linkonce.t.*) 11 + } >ram 12 + }
+52
ld/testsuite/ld-scripts/section-flags.exp
··· 1 + # Test SECTION_FLAGS in a linker script. 2 + # 3 + # This file is part of the GNU Binutils. 4 + # 5 + # This program is free software; you can redistribute it and/or modify 6 + # it under the terms of the GNU General Public License as published by 7 + # the Free Software Foundation; either version 3 of the License, or 8 + # (at your option) any later version. 9 + # 10 + # This program is distributed in the hope that it will be useful, 11 + # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + # GNU General Public License for more details. 14 + # 15 + # You should have received a copy of the GNU General Public License 16 + # along with this program; if not, write to the Free Software 17 + # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 18 + # MA 02110-1301, USA. 19 + 20 + set testname "SECTION_FLAGS-1" 21 + 22 + 23 + # This test only works for ELF targets 24 + if {! [is_elf_format]} { 25 + unsupported $testname 26 + return 27 + } 28 + 29 + if ![ld_assemble $as $srcdir/$subdir/section-flags-1.s tmpdir/section-flags-1.o] { 30 + unresolved $testname 31 + return 32 + } 33 + 34 + if ![ld_simple_link $ld tmpdir/section-flags-1 "-T $srcdir/$subdir/section-flags-1.t tmpdir/section-flags-1.o"] { 35 + fail $testname 36 + return 37 + } 38 + 39 + pass $testname 40 + 41 + set testname "SECTION_FLAGS-2" 42 + if ![ld_assemble $as $srcdir/$subdir/section-flags-2.s tmpdir/section-flags-2.o] { 43 + unresolved $testname 44 + return 45 + } 46 + 47 + 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"] { 48 + fail $testname 49 + return 50 + } 51 + 52 + pass $testname