Index: third_party/yasm/patched-yasm/modules/objfmts/macho/macho-objfmt.c |
=================================================================== |
--- third_party/yasm/patched-yasm/modules/objfmts/macho/macho-objfmt.c (revision 71129) |
+++ third_party/yasm/patched-yasm/modules/objfmts/macho/macho-objfmt.c (working copy) |
@@ -91,7 +91,7 @@ |
*/ |
#include <util.h> |
-/*@unused@*/ RCSID("$Id: macho-objfmt.c 2166 2009-01-02 08:33:21Z peter $"); |
+/*@unused@*/ RCSID("$Id: macho-objfmt.c 2345 2010-08-01 01:27:40Z peter $"); |
#include <libyasm.h> |
@@ -532,7 +532,7 @@ |
if ((vis & YASM_SYM_EXTERN) || (vis & YASM_SYM_COMMON)) { |
reloc->ext = 1; |
info->msd->extreloc = 1; /* section has external relocations */ |
- } else if (!value->curpos_rel && !info->is_64) { |
+ } else if (!info->is_64) { |
/*@dependent@*/ /*@null@*/ yasm_bytecode *sym_precbc; |
/* Local symbols need valued to their actual address */ |
@@ -1001,7 +1001,7 @@ |
unsigned long delta = msd->vmoff % align; |
if (delta > 0) { |
msd->vmoff += align - delta; |
- info->vmsize += delta; |
+ info->vmsize += align - delta; |
} |
} |
@@ -1188,7 +1188,7 @@ |
/* next: section headers */ |
/* offset to relocs for first section */ |
- info.rel_base = align32((long)fileoffset + (long)info.filesize); |
+ info.rel_base = align32((long)fileoff_sections); |
info.s_reloff = 0; /* offset for relocs of following sections */ |
yasm_object_sections_traverse(object, &info, macho_objfmt_output_secthead); |
@@ -1217,8 +1217,8 @@ |
} |
/* padding to long boundary */ |
- if (info.rel_base - (fileoffset + info.filesize)) { |
- fwrite(pad_data, info.rel_base - (fileoffset + info.filesize), 1, f); |
+ if ((info.rel_base - fileoff_sections) > 0) { |
+ fwrite(pad_data, info.rel_base - fileoff_sections, 1, f); |
} |
/* relocation data */ |
@@ -1242,10 +1242,11 @@ |
yasm_xfree(objfmt); |
} |
-static macho_section_data * |
-macho_objfmt_init_new_section(yasm_object *object, yasm_section *sect, |
- const char *sectname, unsigned long line) |
+static void |
+macho_objfmt_init_new_section(yasm_section *sect, unsigned long line) |
{ |
+ yasm_object *object = yasm_section_get_object(sect); |
+ const char *sectname = yasm_section_get_name(sect); |
yasm_objfmt_macho *objfmt_macho = (yasm_objfmt_macho *)object->objfmt; |
macho_section_data *data; |
yasm_symrec *sym; |
@@ -1265,7 +1266,6 @@ |
sym = yasm_symtab_define_label(object->symtab, sectname, |
yasm_section_bcs_first(sect), 1, line); |
data->sym = sym; |
- return data; |
} |
static yasm_section * |
@@ -1278,7 +1278,7 @@ |
retval = yasm_object_get_general(object, "LC_SEGMENT.__TEXT.__text", 0, 1, |
0, &isnew, 0); |
if (isnew) { |
- msd = macho_objfmt_init_new_section(object, retval, ".text", 0); |
+ msd = yasm_section_get_data(retval, &macho_section_data_cb); |
msd->segname = yasm__xstrdup("__TEXT"); |
msd->sectname = yasm__xstrdup("__text"); |
msd->flags = S_ATTR_PURE_INSTRUCTIONS; |
@@ -1471,10 +1471,7 @@ |
&isnew, line); |
yasm_xfree(realname); |
- if (isnew) |
- msd = macho_objfmt_init_new_section(object, retval, sectname, line); |
- else |
- msd = yasm_section_get_data(retval, &macho_section_data_cb); |
+ msd = yasm_section_get_data(retval, &macho_section_data_cb); |
if (isnew || yasm_section_is_default(retval)) { |
yasm_section_set_default(retval, 0); |
@@ -1564,6 +1561,7 @@ |
macho_objfmt_output, |
macho_objfmt_destroy, |
macho_objfmt_add_default_section, |
+ macho_objfmt_init_new_section, |
macho_objfmt_section_switch, |
macho_objfmt_get_special_sym |
}; |
@@ -1582,6 +1580,7 @@ |
macho_objfmt_output, |
macho_objfmt_destroy, |
macho_objfmt_add_default_section, |
+ macho_objfmt_init_new_section, |
macho_objfmt_section_switch, |
macho_objfmt_get_special_sym |
}; |
@@ -1600,6 +1599,7 @@ |
macho_objfmt_output, |
macho_objfmt_destroy, |
macho_objfmt_add_default_section, |
+ macho_objfmt_init_new_section, |
macho_objfmt_section_switch, |
macho_objfmt_get_special_sym |
}; |