elf_object.cc (4484:7c56a6c9c265) elf_object.cc (5070:3d6a1e37b944)
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;

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

338}
339
340bool
341ElfObject::loadLocalSymbols(SymbolTable *symtab, Addr addrMask)
342{
343 return loadSomeSymbols(symtab, STB_LOCAL);
344}
345
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;

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

338}
339
340bool
341ElfObject::loadLocalSymbols(SymbolTable *symtab, Addr addrMask)
342{
343 return loadSomeSymbols(symtab, STB_LOCAL);
344}
345
346bool
347ElfObject::isDynamic()
346void
347ElfObject::getSections()
348{
349 Elf *elf;
350 int sec_idx = 1; // there is a 0 but it is nothing, go figure
351 Elf_Scn *section;
352 GElf_Shdr shdr;
353
354 GElf_Ehdr ehdr;
355
348{
349 Elf *elf;
350 int sec_idx = 1; // there is a 0 but it is nothing, go figure
351 Elf_Scn *section;
352 GElf_Shdr shdr;
353
354 GElf_Ehdr ehdr;
355
356 assert(!sectionNames.size());
357
356 // check that header matches library version
357 if (elf_version(EV_CURRENT) == EV_NONE)
358 panic("wrong elf version number!");
359
360 // get a pointer to elf structure
361 elf = elf_memory((char*)fileData,len);
362 assert(elf != NULL);
363
364 // Check that we actually have a elf file
365 if (gelf_getehdr(elf, &ehdr) ==0) {
366 panic("Not ELF, shouldn't be here");
367 }
368
369 // Get the first section
370 section = elf_getscn(elf, sec_idx);
371
372 // While there are no more sections
373 while (section != NULL) {
374 gelf_getshdr(section, &shdr);
358 // check that header matches library version
359 if (elf_version(EV_CURRENT) == EV_NONE)
360 panic("wrong elf version number!");
361
362 // get a pointer to elf structure
363 elf = elf_memory((char*)fileData,len);
364 assert(elf != NULL);
365
366 // Check that we actually have a elf file
367 if (gelf_getehdr(elf, &ehdr) ==0) {
368 panic("Not ELF, shouldn't be here");
369 }
370
371 // Get the first section
372 section = elf_getscn(elf, sec_idx);
373
374 // While there are no more sections
375 while (section != NULL) {
376 gelf_getshdr(section, &shdr);
375 if (!strcmp(".interp", elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name)))
376 return true;
377 sectionNames.insert(elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name));
377 section = elf_getscn(elf, ++sec_idx);
378 } // while sections
378 section = elf_getscn(elf, ++sec_idx);
379 } // while sections
379 return false;
380}
381
380}
381
382bool
383ElfObject::sectionExists(string sec)
384{
385 if (!sectionNames.size())
386 getSections();
387 return sectionNames.find(sec) != sectionNames.end();
388}
382
389
390