This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [Patch gas/mach-o] try to specify section flags better
- From: Tristan Gingold <gingold at adacore dot com>
- To: Iain Sandoe <developer at sandoe-acoustics dot co dot uk>
- Cc: binutils Development <binutils at sourceware dot org>
- Date: Mon, 20 Feb 2012 17:37:38 +0100
- Subject: Re: [Patch gas/mach-o] try to specify section flags better
- References: <1140A021-F50B-40DE-87D2-0132AA54EF00@sandoe-acoustics.co.uk>
On Feb 18, 2012, at 12:50 PM, Iain Sandoe wrote:
> I found in some tests, that:
> align x
> was causing the alignment padding to be zeroes - and thus broken.
>
> This was caused by section definitions from GCC for various hot/cold/startup etc. sections which are specified the long-hand way (rather than via a canonical name).
>
> The solution is to examine the incoming information and try to set the section flags from that, if possible. This is adequate for the GCC output - but, in the general case it might be wise for people to write
> align x,<nop>
>
> A similar scenario causes relocation problems if we don't recognize debug sections.
>
> OK?
Yes. That makes sense.
I think you should add a comment here too (just the one from ChangeLog would be ok).
Tristan.
> Iain
>
>
> gas:
> * config/obj-macho.c (obj_mach_o_make_or_get_sect): In the absence of
> canonical information, try to determine CODE and DEBUG section flags
> from the mach-o section data.
>
> --- gas/config/obj-macho.c 2012-02-12 15:42:47.000000000 +0000
> +++ gas/config/obj-macho-b.c 2012-02-18 11:42:43.000000000 +0000
> @@ -240,6 +240,16 @@ obj_mach_o_make_or_get_sect (char * segn
>
> if (oldflags == SEC_NO_FLAGS)
> {
> + if (flags == SEC_NO_FLAGS
> + && (specified_mask & SECT_ATTR_SPECIFIED)
> + && (secattr & BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS))
> + flags |= SEC_CODE;
> +
> + if (flags == SEC_NO_FLAGS
> + && (specified_mask & SECT_ATTR_SPECIFIED)
> + && (secattr & BFD_MACH_O_S_ATTR_DEBUG))
> + flags |= SEC_DEBUGGING;
> +
> /* New, so just use the defaults or what's specified. */
> if (! bfd_set_section_flags (stdoutput, sec, flags))
> as_warn (_("failed to set flags for \"%s\": %s"),
>