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]

Re: [Patch mach-o/gas 1/2] support stabs


On Dec 31, 2011, at 2:26 PM, Iain Sandoe wrote:

> -gstabs is still a valid flag for GCC on Darwin (although it probably is almost irrelevant for 64bit and newer systems).  Nevertheless we need to support it for now.
> 
> ... just for once the patches to add it are quite small ;-)

Ok.  Please, check the indentation of obj_macho_process_stab before committing.

Tristan.


> 
> Patch 1 applies independently, patch 2 applies on top of symbol handling patches.
> 
> OK?
> Iain
> 
> bfd:
> 
> 	* mach-o.c (bfd_mach_o_mangle_symbols): Put in the section index
> 	for stabd symbols.
> 
> gas:
> 
> 	* config/obj-macho.c (obj_macho_process_stab): New.
> 	* config/obj-macho.h (OBJ_PROCESS_STAB, obj_macho_process_stab): Define.
> 
> bfd/mach-o.c           |    6 ++++--
> gas/config/obj-macho.c |   40 ++++++++++++++++++++++++++++++++++++++++
> gas/config/obj-macho.h |    3 +++
> gas/stabs.c            |    3 +++
> 4 files changed, 50 insertions(+), 2 deletions(-)
> 
> diff --git a/bfd/mach-o.c b/bfd/mach-o.c
> index cc68d89..920340e 100644
> --- a/bfd/mach-o.c
> +++ b/bfd/mach-o.c
> @@ -1456,10 +1456,12 @@ bfd_mach_o_mangle_symbols (bfd *abfd)
>         }
> 
>       /* Compute section index.  */
> -      if (s->symbol.section != bfd_abs_section_ptr
> +      if ((s->symbol.section != bfd_abs_section_ptr
>           && s->symbol.section != bfd_und_section_ptr
>           && s->symbol.section != bfd_com_section_ptr)
> -        s->n_sect = s->symbol.section->target_index;
> +          || ((s->n_type & BFD_MACH_O_N_STAB) != 0
> +               && s->symbol.name == NULL))
> +	s->n_sect = s->symbol.section->target_index;
> 
>       /* Number symbols.  */
>       s->symbol.udata.i = i;
> diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
> index 74fb0c9..db2146a 100644
> --- a/gas/config/obj-macho.c
> +++ b/gas/config/obj-macho.c
> @@ -850,3 +850,43 @@ const pseudo_typeS mach_o_pseudo_table[] =
> 
>   {NULL, NULL, 0}
> };
> +
> +/* Support stabs for mach-o.  */
> +
> +void
> +obj_macho_process_stab (int what, const char *string,
> +			int type, int other, int desc)
> +{
> +  symbolS *symbolP;
> +  bfd_mach_o_asymbol *s;
> +
> +  switch (what)
> +    {
> +      case 'd':
> +        symbolP = symbol_new ("", now_seg, frag_now_fix (), frag_now);
> +        /* Special stabd NULL name indicator.  */
> +	S_SET_NAME (symbolP, NULL);
> +	break;
> +
> +      case 'n':
> +      case 's':
> +        symbolP = symbol_new (string, undefined_section, (valueT) 0,
> +			      &zero_address_frag);
> +	pseudo_set (symbolP);
> +	break;
> +
> +      default:
> +	as_bad(_("unrecognized stab type '%c'"), (char)what);
> +	abort ();
> +	break;
> +    }
> +
> +   s = (bfd_mach_o_asymbol *) symbol_get_bfdsym (symbolP);
> +    s->n_type = type;
> +    s->n_desc = desc;
> +   /* For stabd, this will eventually get overwritten by the section number.  */
> +   s->n_sect = other;
> +
> +   /* ... and that it's a debug symbol.  */
> +   s->symbol.flags |= BSF_DEBUGGING;
> +}
> diff --git a/gas/config/obj-macho.h b/gas/config/obj-macho.h
> index d9b0b33..3678259 100644
> --- a/gas/config/obj-macho.h
> +++ b/gas/config/obj-macho.h
> @@ -58,4 +58,7 @@ extern const pseudo_typeS mach_o_pseudo_table[];
> 
> #define EMIT_SECTION_SYMBOLS		0
> 
> +#define OBJ_PROCESS_STAB(SEG,W,S,T,O,D)	obj_macho_process_stab(W,S,T,O,D)
> +extern void obj_macho_process_stab (int, const char *,int, int, int);
> +
> #endif /* _OBJ_MACH_O_H */
> 


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