elf_object.cc (10360:919c02740209) elf_object.cc (10810:683ab55819fd)
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

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

145 opSys = ObjectFile::Solaris;
146 break;
147 case ELFOSABI_TRU64:
148 opSys = ObjectFile::Tru64;
149 break;
150 case ELFOSABI_ARM:
151 opSys = ObjectFile::LinuxArmOABI;
152 break;
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

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

145 opSys = ObjectFile::Solaris;
146 break;
147 case ELFOSABI_TRU64:
148 opSys = ObjectFile::Tru64;
149 break;
150 case ELFOSABI_ARM:
151 opSys = ObjectFile::LinuxArmOABI;
152 break;
153 case ELFOSABI_FREEBSD:
154 opSys = ObjectFile::FreeBSD;
155 break;
153 default:
154 opSys = ObjectFile::UnknownOpSys;
155 }
156
157 //take a look at the .note.ABI section
158 //It can let us know what's what.
159 if (opSys == ObjectFile::UnknownOpSys) {
160 Elf_Scn *section;
161 GElf_Shdr shdr;
162 Elf_Data *data;
156 default:
157 opSys = ObjectFile::UnknownOpSys;
158 }
159
160 //take a look at the .note.ABI section
161 //It can let us know what's what.
162 if (opSys == ObjectFile::UnknownOpSys) {
163 Elf_Scn *section;
164 GElf_Shdr shdr;
165 Elf_Data *data;
163 uint32_t osAbi;;
166 uint32_t osAbi;
167 uint32_t *elem;
164 int secIdx = 1;
165
166 // Get the first section
167 section = elf_getscn(elf, secIdx);
168
169 // While there are no more sections
170 while (section != NULL && opSys == ObjectFile::UnknownOpSys) {
171 gelf_getshdr(section, &shdr);

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

189 opSys = ObjectFile::Solaris;
190 break;
191 }
192 } // if section found
193 if (!strcmp(".SUNW_version", elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name)))
194 opSys = ObjectFile::Solaris;
195 if (!strcmp(".stab.index", elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name)))
196 opSys = ObjectFile::Solaris;
168 int secIdx = 1;
169
170 // Get the first section
171 section = elf_getscn(elf, secIdx);
172
173 // While there are no more sections
174 while (section != NULL && opSys == ObjectFile::UnknownOpSys) {
175 gelf_getshdr(section, &shdr);

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

193 opSys = ObjectFile::Solaris;
194 break;
195 }
196 } // if section found
197 if (!strcmp(".SUNW_version", elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name)))
198 opSys = ObjectFile::Solaris;
199 if (!strcmp(".stab.index", elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name)))
200 opSys = ObjectFile::Solaris;
201 if (shdr.sh_type == SHT_NOTE && !strcmp(".note.tag",
202 elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name))) {
203 data = elf_rawdata(section, NULL);
204 assert(data->d_buf);
205 elem = (uint32_t *)data->d_buf;
206 if (elem[0] == 0x8) { //size of name
207 if (memcmp((void *)&elem[3], "FreeBSD", 0x8) == 0)
208 opSys = ObjectFile::FreeBSD;
209 }
210 }
197
198 section = elf_getscn(elf, ++secIdx);
199 } // while sections
200 }
201
202 ElfObject * result = new ElfObject(fname, fd, len, data, arch, opSys);
203
204 //The number of headers in the file

--- 297 unchanged lines hidden ---
211
212 section = elf_getscn(elf, ++secIdx);
213 } // while sections
214 }
215
216 ElfObject * result = new ElfObject(fname, fd, len, data, arch, opSys);
217
218 //The number of headers in the file

--- 297 unchanged lines hidden ---