summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/base')
-rw-r--r--src/base/loader/elf_object.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/base/loader/elf_object.cc b/src/base/loader/elf_object.cc
index 6fcbd0ae3..1b1841a45 100644
--- a/src/base/loader/elf_object.cc
+++ b/src/base/loader/elf_object.cc
@@ -266,12 +266,20 @@ ElfObject::ElfObject(const string &_filename, int _fd,
gelf_getshdr(section, &shdr);
char * secName = elf_strptr(elf, ehdr.e_shstrndx, shdr.sh_name);
- if (!strcmp(".text", secName)) {
- textSecStart = shdr.sh_addr;
- } else if (!strcmp(".data", secName)) {
- dataSecStart = shdr.sh_addr;
- } else if (!strcmp(".bss", secName)) {
- bssSecStart = shdr.sh_addr;
+ if (secName) {
+ if (!strcmp(".text", secName)) {
+ textSecStart = shdr.sh_addr;
+ } else if (!strcmp(".data", secName)) {
+ dataSecStart = shdr.sh_addr;
+ } else if (!strcmp(".bss", secName)) {
+ bssSecStart = shdr.sh_addr;
+ }
+ } else {
+ Elf_Error errorNum = (Elf_Error)elf_errno();
+ if (errorNum != ELF_E_NONE) {
+ const char *errorMessage = elf_errmsg(errorNum);
+ fatal("Error from libelf: %s.\n", errorMessage);
+ }
}
section = elf_getscn(elf, ++secIdx);