public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [Patch gas/mach-o] try to specify section flags better
@ 2012-02-18 11:51 Iain Sandoe
  2012-02-20 16:37 ` Tristan Gingold
  0 siblings, 1 reply; 3+ messages in thread
From: Iain Sandoe @ 2012-02-18 11:51 UTC (permalink / raw)
  To: binutils Development; +Cc: Tristan Gingold

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?
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"),

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch gas/mach-o] try to specify section flags better
  2012-02-18 11:51 [Patch gas/mach-o] try to specify section flags better Iain Sandoe
@ 2012-02-20 16:37 ` Tristan Gingold
  2012-02-20 19:45   ` Iain Sandoe
  0 siblings, 1 reply; 3+ messages in thread
From: Tristan Gingold @ 2012-02-20 16:37 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: binutils Development


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"),
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch gas/mach-o] try to specify section flags better
  2012-02-20 16:37 ` Tristan Gingold
@ 2012-02-20 19:45   ` Iain Sandoe
  0 siblings, 0 replies; 3+ messages in thread
From: Iain Sandoe @ 2012-02-20 19:45 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils Development


On 20 Feb 2012, at 16:37, Tristan Gingold wrote:
>> OK?
>
> Yes.  That makes sense.
> I think you should add a comment here too (just the one from  
> ChangeLog would be ok).

thanks, done & applied.
Iain

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-02-20 19:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-18 11:51 [Patch gas/mach-o] try to specify section flags better Iain Sandoe
2012-02-20 16:37 ` Tristan Gingold
2012-02-20 19:45   ` Iain Sandoe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).