[RFA] Linker script extension SECTION_FLAGS

Catherine Moore clm@codesourcery.com
Tue May 24 22:57:00 GMT 2011


On 05/18/2011 08:07 PM, Ian Lance Taylor wrote:
> Catherine Moore<clm@codesourcery.com>  writes:
>>
>> Does this look okay to install?
>
> I didn't look at the patch, but I think the documentation needs to use
> some real section flags, and ideally the set of valid flags should be
> defined somewhere.  It's not obvious what the valid values are.
>
> I'm also not sure about the way it appears in a linker script.  You have
> SECTION_FLAGS, which describes a constraint on the input sections
> attached to an output section, next to things like AT, ALIGN, and
> SUBALIGN, which describe characteristics of the output section.  That is
> OK, but I think that somebody looking at a linker script is likely to
> think that SECTION_FLAGS is setting flags for the output section, much
> as ALIGN sets the alignment of the output section.  But that's not what
> happens at all.  So perhaps the name should be something like
> INPUT_SECTION_FLAGS or perhaps the constraint should be expressed
> somehow inside the output section definition, in the list of input
> sections, rather than outside.
>

A new patch that addresses these concerns plus a couple that were 
pointed out by Tristan is attached here.  Tristan, I didn't incorporate 
your comment regarding the backend hook into the new patch.  I have now 
filled in bfd_elf_lookup_section_flags to handle all of the ELF common 
section header flags.  The backend hook is intended to handle the 
target-specific flags.  Although, I'm not submitting it at this time, 
the backend hook that I am using for the PowerPC VLE target is attached 
as an example.

Please let me know if there are additional concerns or comments and 
whether this is okay to commit.

I've tested ppc-elf, mips-elf and arm-coff targets.

Thanks,
Catherine

bfd/
2011-05-24  Catherine Moore  <clm@codesourcery.com>

         * 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.


include/
2011-05-24  Catherine Moore  <clm@codesourcery.com>

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

ld/testsuite/
2011-05-24  Catherine Moore  <clm@codesourcery.com>

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


ld/2011-05-23  Catherine Moore  <clm@codesourcery.com>

	* ld.texinfo: Document usage of INPUT_SECTION_FLAGS.
	* ldgram.y (section): Recognize sect_flags.
	(sect_flags): New rule.
	(sect_flag_list): New rule.
	* ldlang.c (lang_add_section): Check section flags.
	(lang_enter_output_section_statement): Add argument sflags.
	Initialize sflags field in output statement.
	* ldlang.h (lang_output_section_statement_type): Add flag_info field.
	(lang_enter_output_section_statement): New argument sflags.  Update
	all callers.
	* ldlex.l (INPUT_SECTION_FLAGS): New token.
	* mri.c (mri_draw_tree): Update argument list for
	land_enter_output_section_statement.




-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: sf.patch2
URL: <https://sourceware.org/pipermail/binutils/attachments/20110524/7b3ccaa2/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ppc-backend.patch
Type: text/x-patch
Size: 814 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20110524/7b3ccaa2/attachment.bin>


More information about the Binutils mailing list