Deleted Added
sdiff udiff text old ( 9810:e895db06e69f ) new ( 10037:5cac77888310 )
full compact
1/*
2 * Copyright (c) 2011-2013 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2003-2005 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright

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

68 panic("wrong elf version number!");
69
70 // get a pointer to elf structure
71 elf = elf_memory((char*)data,len);
72 // will only fail if fd is invalid
73 assert(elf != NULL);
74
75 // Check that we actually have a elf file
76 if (gelf_getehdr(elf, &ehdr) == 0) {
77 DPRINTFR(Loader, "Not ELF\n");
78 elf_end(elf);
79 return NULL;
80 } else {
81 //Detect the architecture
82 //Since we don't know how to check for alpha right now, we'll
83 //just assume if it wasn't something else and it's 64 bit, that's
84 //what it must be.

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

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

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

215 result->_programHeaderTable = 0;
216 for(int hdrnum = 0; hdrnum < result->_programHeaderCount; hdrnum++)
217 {
218 gelf_getphdr(elf, hdrnum, &phdr);
219 //Check if we've found the segment with the headers in it
220 if(phdr.p_offset <= e_phoff &&
221 phdr.p_offset + phdr.p_filesz > e_phoff)
222 {
223 result->_programHeaderTable =
224 phdr.p_paddr + (e_phoff - phdr.p_offset);
225 break;
226 }
227 }
228 }
229 else
230 result->_programHeaderTable = 0;
231
232

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

433
434bool
435ElfObject::loadWeakSymbols(SymbolTable *symtab, Addr addrMask)
436{
437 return loadSomeSymbols(symtab, STB_WEAK, addrMask);
438}
439
440bool
441ElfObject::loadSections(PortProxy& memProxy, Addr addrMask, Addr offset)
442{
443 if (!ObjectFile::loadSections(memProxy, addrMask, offset))
444 return false;
445
446 vector<Segment>::iterator extraIt;
447 for (extraIt = extraSegments.begin();
448 extraIt != extraSegments.end(); extraIt++) {
449 if (!loadSection(&(*extraIt), memProxy, addrMask, offset)) {
450 return false;
451 }
452 }
453 return true;
454}
455
456void
457ElfObject::getSections()

--- 43 unchanged lines hidden ---