X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=sim%2Fmips%2Finterp.c;h=9dbac8c58fc76f8a3e54c9819037c25bc0a495b6;hb=a78a19b15254de31c3d38b7e27469aaef0a30e97;hp=61ff400be1b8c2f74f93da52442cf34f958e3902;hpb=2e3d4f4d5d386995e99d035354a9e411d1dc0331;p=deliverable%2Fbinutils-gdb.git diff --git a/sim/mips/interp.c b/sim/mips/interp.c index 61ff400be1..9dbac8c58f 100644 --- a/sim/mips/interp.c +++ b/sim/mips/interp.c @@ -55,6 +55,7 @@ code on the hardware. #include "getopt.h" #include "libiberty.h" #include "bfd.h" +#include "elf-bfd.h" #include "gdb/callback.h" /* GDB simulator callback interface */ #include "gdb/remote-sim.h" /* GDB simulator interface */ @@ -1020,7 +1021,17 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd, for (cpu_nr = 0; cpu_nr < sim_engine_nr_cpus (sd); cpu_nr++) { sim_cpu *cpu = STATE_CPU (sd, cpu_nr); - CPU_PC_SET (cpu, (unsigned64) bfd_get_start_address (abfd)); + sim_cia pc = bfd_get_start_address (abfd); + + /* We need to undo brain-dead bfd behavior where it sign-extends + addresses that are supposed to be unsigned. See the mips bfd + sign_extend_vma setting. We have to check the ELF data itself + in order to handle o32 & n32 ABIs. */ + if (abfd->tdata.elf_obj_data->elf_header->e_ident[EI_CLASS] == + ELFCLASS32) + pc = (unsigned32) pc; + + CPU_PC_SET (cpu, pc); } }