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 mach-o/gas 2/2] support stabs


this applies on top of:
http://sourceware.org/ml/binutils/2011-12/msg00319.html
and
http://sourceware.org/ml/binutils/2011-12/msg00320.html
and Patch 1.

it modifies the symbol handling and sorting to deal with stabs.

OK?
Iain

bfd:

	* mach-o.c (bfd_mach_o_primary_symbol_sort_key): Adjust for stabs.
	(bfd_mach_o_cf_symbols): Likewise.

gas:

	* config/obj-macho.c (obj_macho_frob_label): Leave stabs untouched.
	(obj_macho_frob_symbol): Likewise.

diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index cf54471..856d245 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -1610,15 +1610,19 @@ 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) return 3;
+ 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) return 0;
+ 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) return 2;
+ if (mtyp == BFD_MACH_O_N_UNDF) return 2;
/* A defined symbol that's not indirect or extern. */
return 1;
}
@@ -1629,19 +1633,15 @@ bfd_mach_o_cf_symbols (const void *a, const void *b)
bfd_mach_o_asymbol *sa = *(bfd_mach_o_asymbol **) a;
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)


diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
index 8007123..ad442d2 100644
--- a/gas/config/obj-macho.c
+++ b/gas/config/obj-macho.c
@@ -773,6 +773,9 @@ void obj_macho_frob_label (struct symbol *sp)
unsigned base_type = obj_mach_o_type_for_symbol (s);
bfd_mach_o_section *sec = bfd_mach_o_get_mach_o_section (s- >symbol.section);
int sectype = -1;
+
+ if ((s->n_type & BFD_MACH_O_N_STAB) != 0)
+ return; /* Leave alone. */


   if (sec != NULL)
     sectype = sec->flags & BFD_MACH_O_SECTION_TYPE_MASK;
@@ -789,7 +792,6 @@ void obj_macho_frob_label (struct symbol *sp)

       /* Have we changed from an undefined to defined ref? */
       s->n_desc &= ~(REFE | LAZY);
-
     }

   if ((s->n_type & BFD_MACH_O_N_TYPE) == BFD_MACH_O_N_INDR)
@@ -816,7 +818,9 @@ obj_macho_frob_symbol (struct symbol *sp)
   if (sec != NULL)
     sectype = sec->flags & BFD_MACH_O_SECTION_TYPE_MASK;

- if (s->symbol.section == bfd_und_section_ptr)
+ if ((s->n_type & BFD_MACH_O_N_STAB) != 0)
+ return 0; /* Leave alone. */
+ else if (s->symbol.section == bfd_und_section_ptr)
{
/* ??? Do we really gain much from implementing this as well as the
mach-o specific ones? */



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