Deleted Added
sdiff udiff text old ( 9810:e895db06e69f ) new ( 10037:5cac77888310 )
full compact
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright

--- 46 unchanged lines hidden (view full) ---

56 panic("wrong elf version number!");
57
58 // get a pointer to elf structure
59 elf = elf_memory((char*)data,len);
60 // will only fail if fd is invalid
61 assert(elf != NULL);
62
63 // Check that we actually have a elf file
64 if (gelf_getehdr(elf, &ehdr) ==0) {
65 DPRINTFR(Loader, "Not ELF\n");
66 elf_end(elf);
67 return NULL;
68 } else {
69 //Detect the architecture
70 //Since we don't know how to check for alpha right now, we'll
71 //just assume if it wasn't something else and it's 64 bit, that's
72 //what it must be.

--- 16 unchanged lines hidden (view full) ---

89 "Please recompile your binary.\n");
90 }
91 } else if (ehdr.e_machine == EM_X86_64 &&
92 ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
93 arch = ObjectFile::X86_64;
94 } else if (ehdr.e_machine == EM_386 &&
95 ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
96 arch = ObjectFile::I386;
97 } else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
98 arch = ObjectFile::Alpha;
99 } else if (ehdr.e_machine == EM_ARM) {
100 if (bits(ehdr.e_entry, 0)) {
101 arch = ObjectFile::Thumb;
102 } else {
103 arch = ObjectFile::Arm;
104 }
105 } else if (ehdr.e_machine == EM_PPC &&
106 ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
107 if (ehdr.e_ident[EI_DATA] == ELFDATA2MSB) {
108 arch = ObjectFile::Power;
109 } else {
110 fatal("The binary you're trying to load is compiled for "
111 "little endian Power.\nM5 only supports big "
112 "endian Power. Please recompile your binary.\n");
113 }
114 } else if (ehdr.e_machine == EM_PPC64) {
115 fatal("The binary you're trying to load is compiled for 64-bit "
116 "Power. M5\n only supports 32-bit Power. Please "
117 "recompile your binary.\n");
118 } else {
119 warn("Unknown architecture: %d\n", ehdr.e_machine);
120 arch = ObjectFile::UnknownArch;
121 }
122
123 //Detect the operating system
124 switch (ehdr.e_ident[EI_OSABI])
125 {
126
127 case ELFOSABI_LINUX:
128 opSys = ObjectFile::Linux;
129 break;
130 case ELFOSABI_SOLARIS:
131 opSys = ObjectFile::Solaris;
132 break;
133 case ELFOSABI_TRU64:
134 opSys = ObjectFile::Tru64;

--- 66 unchanged lines hidden (view full) ---

201 result->_programHeaderTable = 0;
202 for(int hdrnum = 0; hdrnum < result->_programHeaderCount; hdrnum++)
203 {
204 gelf_getphdr(elf, hdrnum, &phdr);
205 //Check if we've found the segment with the headers in it
206 if(phdr.p_offset <= e_phoff &&
207 phdr.p_offset + phdr.p_filesz > e_phoff)
208 {
209 result->_programHeaderTable = phdr.p_paddr + e_phoff;
210 break;
211 }
212 }
213 }
214 else
215 result->_programHeaderTable = 0;
216
217

--- 200 unchanged lines hidden (view full) ---

418
419bool
420ElfObject::loadWeakSymbols(SymbolTable *symtab, Addr addrMask)
421{
422 return loadSomeSymbols(symtab, STB_WEAK, addrMask);
423}
424
425bool
426ElfObject::loadSections(PortProxy& memProxy, Addr addrMask)
427{
428 if (!ObjectFile::loadSections(memProxy, addrMask))
429 return false;
430
431 vector<Segment>::iterator extraIt;
432 for (extraIt = extraSegments.begin();
433 extraIt != extraSegments.end(); extraIt++) {
434 if (!loadSection(&(*extraIt), memProxy, addrMask)) {
435 return false;
436 }
437 }
438 return true;
439}
440
441void
442ElfObject::getSections()

--- 43 unchanged lines hidden ---