support stabs on mach-o GAS.
bfd: * mach-o.c (bfd_mach_o_mangle_symbols): Put in the section index for stabd symbols. (bfd_mach_o_primary_symbol_sort_key): Adjust for stabs. (bfd_mach_o_cf_symbols): Likewise. gas: * config/obj-macho.c (obj_macho_process_stab): New. * config/obj-macho.h (OBJ_PROCESS_STAB): Define. (obj_macho_process_stab): Declare.
This commit is contained in:
parent
f2b324f1f9
commit
68588f9540
5 changed files with 77 additions and 17 deletions
|
@ -1,3 +1,10 @@
|
|||
2012-01-03 Iain Sandoe <idsandoe@googlemail.com>
|
||||
|
||||
* mach-o.c (bfd_mach_o_mangle_symbols): Put in the section index
|
||||
for stabd symbols.
|
||||
(bfd_mach_o_primary_symbol_sort_key): Adjust for stabs.
|
||||
(bfd_mach_o_cf_symbols): Likewise.
|
||||
|
||||
2012-01-03 Iain Sandoe <idsandoe@googlemail.com>
|
||||
|
||||
* mach-o.c (bfd_mach_o_mangle_symbols): Correct typo.
|
||||
|
|
34
bfd/mach-o.c
34
bfd/mach-o.c
|
@ -1625,19 +1625,25 @@ bfd_mach_o_write_dysymtab (bfd *abfd, bfd_mach_o_load_command *command)
|
|||
}
|
||||
|
||||
static unsigned
|
||||
bfd_mach_o_primary_symbol_sort_key (unsigned type, unsigned ext)
|
||||
bfd_mach_o_primary_symbol_sort_key (unsigned type)
|
||||
{
|
||||
/* TODO: Determine the correct ordering of stabs symbols. */
|
||||
/* We make indirect symbols a local/synthetic. */
|
||||
if (type == BFD_MACH_O_N_INDR)
|
||||
unsigned mtyp = type & BFD_MACH_O_N_TYPE;
|
||||
|
||||
/* Just leave debug symbols where they are (pretend they are local, and
|
||||
then they will just be sorted on position). */
|
||||
if (type & BFD_MACH_O_N_STAB)
|
||||
return 0;
|
||||
|
||||
/* Sort indirects to last. */
|
||||
if (mtyp == BFD_MACH_O_N_INDR)
|
||||
return 3;
|
||||
|
||||
/* Local (we should never see an undefined local AFAICT). */
|
||||
if (! ext)
|
||||
if (! (type & (BFD_MACH_O_N_EXT | BFD_MACH_O_N_PEXT)))
|
||||
return 0;
|
||||
|
||||
/* Common symbols look like undefined externs. */
|
||||
if (type == BFD_MACH_O_N_UNDF)
|
||||
if (mtyp == BFD_MACH_O_N_UNDF)
|
||||
return 2;
|
||||
|
||||
/* A defined symbol that's not indirect or extern. */
|
||||
|
@ -1651,19 +1657,15 @@ bfd_mach_o_cf_symbols (const void *a, const void *b)
|
|||
bfd_mach_o_asymbol *sb = *(bfd_mach_o_asymbol **) b;
|
||||
unsigned int soa, sob;
|
||||
|
||||
soa = bfd_mach_o_primary_symbol_sort_key
|
||||
(sa->n_type & BFD_MACH_O_N_TYPE,
|
||||
sa->n_type & (BFD_MACH_O_N_PEXT | BFD_MACH_O_N_EXT));
|
||||
sob = bfd_mach_o_primary_symbol_sort_key
|
||||
(sb->n_type & BFD_MACH_O_N_TYPE,
|
||||
sb->n_type & (BFD_MACH_O_N_PEXT | BFD_MACH_O_N_EXT));
|
||||
soa = bfd_mach_o_primary_symbol_sort_key (sa->n_type);
|
||||
sob = bfd_mach_o_primary_symbol_sort_key (sb->n_type);
|
||||
if (soa < sob)
|
||||
return -1;
|
||||
|
||||
if (soa > sob)
|
||||
return 1;
|
||||
|
||||
/* If it's local, just preserve the input order. */
|
||||
/* If it's local or stab, just preserve the input order. */
|
||||
if (soa == 0)
|
||||
{
|
||||
if (sa->symbol.udata.i < sb->symbol.udata.i)
|
||||
|
@ -1782,10 +1784,12 @@ bfd_mach_o_mangle_symbols (bfd *abfd, bfd_mach_o_data_struct *mdata)
|
|||
}
|
||||
|
||||
/* Put the section index in, where required. */
|
||||
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;
|
||||
|
||||
/* Unless we're looking at an indirect sym, note the input ordering.
|
||||
We use this to keep local symbols ordered as per the input. */
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2012-01-03 Iain Sandoe <idsandoe@googlemail.com>
|
||||
|
||||
* config/obj-macho.c (obj_macho_process_stab): New.
|
||||
* config/obj-macho.h (OBJ_PROCESS_STAB): Define.
|
||||
(obj_macho_process_stab): Declare.
|
||||
|
||||
2011-12-29 Iain Sandoe <idsandoe@googlemail.com>
|
||||
|
||||
* as.c (perform_an_assembly_pass): Do not create text, data and bss
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Mach-O object file format
|
||||
Copyright 2009, 2011 Free Software Foundation, Inc.
|
||||
Copyright 2009, 2011, 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GAS, the GNU Assembler.
|
||||
|
||||
|
@ -850,3 +850,43 @@ const pseudo_typeS mach_o_pseudo_table[] =
|
|||
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
/* Support stabs for mach-o. */
|
||||
|
||||
void
|
||||
obj_mach_o_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;
|
||||
|
||||
/* It's a debug symbol. */
|
||||
s->symbol.flags |= BSF_DEBUGGING;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Mach-O object file format for gas, the assembler.
|
||||
Copyright 2009, 2011 Free Software Foundation, Inc.
|
||||
Copyright 2009, 2011, 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GAS, the GNU Assembler.
|
||||
|
||||
|
@ -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_mach_o_process_stab(W,S,T,O,D)
|
||||
extern void obj_mach_o_process_stab (int, const char *,int, int, int);
|
||||
|
||||
#endif /* _OBJ_MACH_O_H */
|
||||
|
|
Loading…
Reference in a new issue