diff options
author | Ian Lance Taylor <iant@google.com> | 2010-11-17 01:03:06 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-11-17 01:03:06 +0000 |
commit | d82f74d3ab985da4b217a4942a0b4e2e55021fab (patch) | |
tree | 8567ed627560514ebbb02791cf4486d8aac87378 /libiberty/simple-object-elf.c | |
parent | 354d8ce1084fadee6f9761fb6b1d1dd897b69ef4 (diff) | |
download | gcc-d82f74d3ab985da4b217a4942a0b4e2e55021fab.zip gcc-d82f74d3ab985da4b217a4942a0b4e2e55021fab.tar.gz gcc-d82f74d3ab985da4b217a4942a0b4e2e55021fab.tar.bz2 |
simple-object.h (simple_object_attributes_merge): Declare, replacing simple_object_attributes_compare.
include/:
* simple-object.h (simple_object_attributes_merge): Declare,
replacing simple_object_attributes_compare.
libiberty/:
* simple-object.c (simple_object_attributes_merge): Rename from
simple_object_attributes_compare. Call merge field.
* simple-object-common.h (struct simple_object_functions): Rename
attributes_compare field to attribute_merge.
* simple-object-elf.c (EM_SPARC): Define.
(EM_SPARC32PLUS): Define.
(simple_object_elf_attributes_merge): Renamed from
simple_object_elf_attributes_compare. Permit EM_SPARC and
EM_SPARC32PLUS objects to be merged.
(simple_object_elf_functions): Update function name.
* simple-object-coff.c (simple_object_coff_attributes_merge):
Rename from simple_object_coff_attributes_compare.
(simple_object_coff_functions): Update function name.
* simple-object-mach-o.c (simple_object_mach_o_attributes_merge):
Renamed from simple_object_mach_o_attributes_compare.
(simple_object_mach_o_functions): Update function name.
gcc/lto/:
* lto-object.c (lto_obj_file_open): Call
simple_object_attributes_merge rather than
simple_object_attributes_compare.
From-SVN: r166848
Diffstat (limited to 'libiberty/simple-object-elf.c')
-rw-r--r-- | libiberty/simple-object-elf.c | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c index 5b8cfba..4196c53 100644 --- a/libiberty/simple-object-elf.c +++ b/libiberty/simple-object-elf.c @@ -115,6 +115,11 @@ typedef struct { #define ET_REL 1 /* Relocatable file */ +/* Values for e_machine field of Ehdr. */ + +#define EM_SPARC 2 /* SUN SPARC */ +#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ + /* Special section index values. */ #define SHN_LORESERVE 0xFF00 /* Begin range of reserved indices */ @@ -604,20 +609,52 @@ simple_object_elf_release_read (void *data) /* Compare two attributes structures. */ static const char * -simple_object_elf_attributes_compare (void *data1, void *data2, int *err) +simple_object_elf_attributes_merge (void *todata, void *fromdata, int *err) { - struct simple_object_elf_attributes *attrs1 = - (struct simple_object_elf_attributes *) data1; - struct simple_object_elf_attributes *attrs2 = - (struct simple_object_elf_attributes *) data2; - - if (attrs1->ei_data != attrs2->ei_data - || attrs1->ei_class != attrs2->ei_class - || attrs1->machine != attrs2->machine) + struct simple_object_elf_attributes *to = + (struct simple_object_elf_attributes *) todata; + struct simple_object_elf_attributes *from = + (struct simple_object_elf_attributes *) fromdata; + + if (to->ei_data != from->ei_data || to->ei_class != from->ei_class) { *err = 0; return "ELF object format mismatch"; } + + if (to->machine != from->machine) + { + int ok; + + /* EM_SPARC and EM_SPARC32PLUS are compatible and force an + output of EM_SPARC32PLUS. */ + ok = 0; + switch (to->machine) + { + case EM_SPARC: + if (from->machine == EM_SPARC32PLUS) + { + to->machine = from->machine; + ok = 1; + } + break; + + case EM_SPARC32PLUS: + if (from->machine == EM_SPARC) + ok = 1; + break; + + default: + break; + } + + if (!ok) + { + *err = 0; + return "ELF machine number mismatch"; + } + } + return NULL; } @@ -908,7 +945,7 @@ const struct simple_object_functions simple_object_elf_functions = simple_object_elf_find_sections, simple_object_elf_fetch_attributes, simple_object_elf_release_read, - simple_object_elf_attributes_compare, + simple_object_elf_attributes_merge, simple_object_elf_release_attributes, simple_object_elf_start_write, simple_object_elf_write_to_file, |