This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch gas/mach-o] try to specify section flags better


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]