[Patch, mach-o/gas] correct a case where stub size is not filled in by GAS.

Iain Sandoe developer@sandoe-acoustics.co.uk
Thu Feb 9 15:26:00 GMT 2012
On 9 Feb 2012, at 15:17, Tristan Gingold wrote:

>
> On Feb 9, 2012, at 3:28 PM, Iain Sandoe wrote:
>
>> the stub size for well-known-stub sections is not filled in from  
>> the BFD section translation table, but the other flags *are* when  
>> the section type is recognized.
>>
>> This leads to a failure to fill in the stub-size when someone  
>> specifies a well-known stub section by a hand-written section  
>> command. (e.g. darwin.S in libffi).
>
> Sorry, but I still do not understand the patch.  Maybe you should  
> quote the line in darwin.S if this is not this one:
>
> .section __IMPORT,__jump_table,symbol_stubs,self_modifying_code 
> +pure_instructions,5

that's the line.

> Currently, stub_size is always extracted from the .section (but  
> default to 0).  So currently it was set to 5.  What your patch  
> changes on darwin.S ?

the size is extracted correctly and passed to  
obj_mach_o_make_or_get_sect ().

However, when obj_mach_o_make_or_get_sect makes the section - it will  
be provided with default values for the attributes and flags by BFD  
[ which recognizes the section as a 'standard' one].  However, this  
does not include the stub-size, which is not part of our translation  
table at present.

Anyway, in obj_mach_o_make_or_get_sect () we then find that flags !=  
NO_FLAGS and so bypass the code that filled in the stub size.

> Also, I don't understand why stub_size is handled differently from  
> alignment.

Well, it seemed to expand the translation tables a lot for just a  
handful of cases .. it seemed like bloat... I guess we could revisit  
that.

Iain

>> fixed thus:
>>
>> gas:
>>
>> 	* config/obj-macho.c (obj_mach_o_make_or_get_sect): Always fill in  
>> stub size
>> 	when provided.  (obj_mach_o_section): Flag that stub-size has been  
>> provided.
>>
>> diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
>> index ba09780..17a21e6 100644
>> --- a/gas/config/obj-macho.c
>> +++ b/gas/config/obj-macho.c
>> @@ -168,6 +168,7 @@ obj_mach_o_get_section_names (char *seg, char  
>> *sec,
>> #define SECT_TYPE_SPECIFIED 0x0001
>> #define SECT_ATTR_SPECIFIED 0x0002
>> #define SECT_ALGN_SPECIFIED 0x0004
>> +#define SECT_STUB_SPECIFIED 0x0008
>>
>> static segT
>> obj_mach_o_make_or_get_sect (char * segname, char * sectname,
>> @@ -267,7 +268,6 @@ obj_mach_o_make_or_get_sect (char * segname,  
>> char * sectname,
>>
>>      msect->align = secalign;
>>      msect->flags = sectype | secattr;
>> -      msect->reserved2 = stub_size;
>>
>>      if (sectype == BFD_MACH_O_S_ZEROFILL
>> 	  || sectype == BFD_MACH_O_S_GB_ZEROFILL)
>> @@ -280,6 +280,10 @@ obj_mach_o_make_or_get_sect (char * segname,  
>> char * sectname,
>> 	as_warn (_("Ignoring changed section attributes for %s"), name);
>>    }
>>
>> +  if (specified_mask & SECT_STUB_SPECIFIED)
>> +    /* At present, the stub size is not supplied from the BFD  
>> tables.  */
>> +    msect->reserved2 = stub_size;
>> +
>>  return sec;
>> }
>>
>> @@ -413,6 +417,7 @@ obj_mach_o_section (int ignore ATTRIBUTE_UNUSED)
>>
>> 	      input_line_pointer++;
>>              sizeof_stub = get_absolute_expression ();
>> +              specified_mask |= SECT_STUB_SPECIFIED;
>>            }
>>          else if ((specified_mask & SECT_ATTR_SPECIFIED)
>> 		   && sectype == BFD_MACH_O_S_SYMBOL_STUBS)
>>
>



More information about the Binutils mailing list