diff options
author | Ali Saidi <saidi@eecs.umich.edu> | 2006-03-09 15:42:09 -0500 |
---|---|---|
committer | Ali Saidi <saidi@eecs.umich.edu> | 2006-03-09 15:42:09 -0500 |
commit | ce3a6343b6c54e95d63403d46c9ddea384e49476 (patch) | |
tree | 2acc56fa5c2ea2230658ed9b23a17364a241fdab /base | |
parent | ab67095b2a43b5f2d44d1e1a517d1079ddf9f104 (diff) | |
download | gem5-ce3a6343b6c54e95d63403d46c9ddea384e49476.tar.xz |
no more common syscall emulation, now common for everyone
check abi-tag note section of elf binary for OS
add pseudo functions (moved from alpha and made to be generic)
move setsyscallreturn into isa traits
arch/alpha/SConscript:
no more common syscall emulation, now common for everyone
arch/alpha/isa_traits.hh:
move setsyscallreturn into isa description
arch/alpha/linux/process.cc:
arch/alpha/tru64/process.cc:
use generic functions rather than alpha specific ones
arch/sparc/isa_traits.hh:
have consts for generic pseudo syscalls
arch/sparc/linux/process.cc:
use generic functions
base/loader/elf_object.cc:
check abi-tag note section of elf binary for OS
cpu/exec_context.hh:
move syssyscallreturn into isa traits
sim/process.cc:
find call num with a more generic
sim/syscall_emul.cc:
sim/syscall_emul.hh:
add pseudo functions (moved from alpha and made to be generic)
--HG--
extra : convert_revision : 5a31024ecde7e39b830365ddd84593ea501a34d2
Diffstat (limited to 'base')
-rw-r--r-- | base/loader/elf_object.cc | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/base/loader/elf_object.cc b/base/loader/elf_object.cc index fd69c9e56..791c6f6de 100644 --- a/base/loader/elf_object.cc +++ b/base/loader/elf_object.cc @@ -75,15 +75,6 @@ ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data) return NULL; } else { -// if (ehdr.e_ident[EI_CLASS] == ELFCLASS32) -// panic("32 bit ELF Binary, Not Supported"); - /* @todo this emachine value isn't offical yet. - * so we probably shouldn't check it. */ -// if (ehdr.e_machine != EM_ALPHA) -// panic("Non Alpha Binary, Not Supported"); - - elf_end(elf); - //Detect the architecture //Versioning issues in libelf need to be resolved to get the correct //SPARC constants. @@ -109,17 +100,61 @@ ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data) //Detect the operating system switch (ehdr.e_ident[EI_OSABI]) { + case ELFOSABI_LINUX: opSys = ObjectFile::Linux; break; case ELFOSABI_SOLARIS: opSys = ObjectFile::Solaris; + break; case ELFOSABI_TRU64: opSys = ObjectFile::Tru64; + break; default: opSys = ObjectFile::UnknownOpSys; } + //take a look at the .note.ABI section + //It can let us know what's what. + if (opSys == ObjectFile::UnknownOpSys) + { + Elf_Scn *section; + GElf_Shdr shdr; + Elf_Data *data; + uint32_t osAbi;; + int secIdx = 1; + + // Get the first section + section = elf_getscn(elf, secIdx); + + // While there are no more sections + while (section != NULL) { + gelf_getshdr(section, &shdr); + if (shdr.sh_type == SHT_NOTE && !strcmp(".note.ABI-tag", + elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name))) { + // we have found a ABI note section + // Check the 5th 32bit word for OS 0 == linux, 1 == hurd, + // 2 == solaris, 3 == freebsd + data = elf_rawdata(section, NULL); + assert(data->d_buf); + if(ehdr.e_ident[EI_DATA] == ELFDATA2LSB) + osAbi = htole(((uint32_t*)data->d_buf)[4]); + else + osAbi = htobe(((uint32_t*)data->d_buf)[4]); + + switch(osAbi) { + case 0: + opSys = ObjectFile::Linux; + break; + case 2: + opSys = ObjectFile::Solaris; + break; + } + } // if section found + section = elf_getscn(elf, ++secIdx); + } // while sections + } + elf_end(elf); return new ElfObject(fname, fd, len, data, arch, opSys); } } |