summaryrefslogtreecommitdiffstats
path: root/libelf
diff options
context:
space:
mode:
authorUlrich Drepper <[email protected]>2005-08-03 00:02:56 +0000
committerUlrich Drepper <[email protected]>2005-08-03 00:02:56 +0000
commit41de488a0ad6679e816dbab960351e5f62ab8ead (patch)
treed4387847c11e48ccc8fa55ace24bcd2a595d0d84 /libelf
parentc911c9efe553d9af2d4fb0d420d8b614983e16ac (diff)
Add several more elflint tests:
- check whether dynamic section matches PT_DYNAMIC program header entry - make sure text relocation flag is used correctly libelf needed one extension for this.
Diffstat (limited to 'libelf')
-rw-r--r--libelf/ChangeLog10
-rw-r--r--libelf/Makefile.am3
-rw-r--r--libelf/elf_error.c8
-rw-r--r--libelf/gelf.h3
-rw-r--r--libelf/libelf.h7
-rw-r--r--libelf/libelf.map3
-rw-r--r--libelf/libelfP.h5
7 files changed, 36 insertions, 3 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index caa2b5bc..6a1dfd93 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,13 @@
+2005-08-02 Ulrich Drepper <[email protected]>
+
+ * elf_error.c: Add handling of ELF_E_INVALID_OFFSET.
+ * elf32_offscn.c: New file.
+ * elf64_offscn.c: New file.
+ * gelf_offscn.c: New file.
+ * Makefile.am (libelf_a_SOURCES): Add elf32_offscn.c, elf64_offscn.c,
+ and gelf_offscn.c.
+ * libelf.sym: Export new symbols.
+
2005-07-23 Ulrich Drepper <[email protected]>
* elf-knowledge.h (SECTION_STRIP_P): Don't handle removal of debug
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index cf581902..d9caac65 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -79,7 +79,8 @@ libelf_a_SOURCES = elf_version.c elf_hash.c elf_error.c elf_fill.c \
gelf_rawchunk.c gelf_freechunk.c \
libelf_crc32.c libelf_next_prime.c \
elf_clone.c \
- gelf_getlib.c gelf_update_lib.c
+ gelf_getlib.c gelf_update_lib.c \
+ elf32_offscn.c elf64_offscn.c gelf_offscn.c
if !MUDFLAP
libelf_pic_a_SOURCES =
diff --git a/libelf/elf_error.c b/libelf/elf_error.c
index 168ce113..b51962b9 100644
--- a/libelf/elf_error.c
+++ b/libelf/elf_error.c
@@ -243,6 +243,11 @@ static const char msgstr[] =
(ELF_E_INVALID_PHDR_IDX \
+ sizeof "program header only allowed in executables and shared objects")
N_("file has no program header")
+ "\0"
+#define ELF_E_INVALID_OFFSET_IDX \
+ (ELF_E_NO_PHDR_IDX \
+ + sizeof "file has no program header")
+ N_("invalid offset")
};
@@ -289,7 +294,8 @@ static const uint_fast16_t msgidx[ELF_E_NUM] =
[ELF_E_NOFILE] = ELF_E_NOFILE_IDX,
[ELF_E_GROUP_NOT_REL] = ELF_E_GROUP_NOT_REL_IDX,
[ELF_E_INVALID_PHDR] = ELF_E_INVALID_PHDR_IDX,
- [ELF_E_NO_PHDR] = ELF_E_NO_PHDR_IDX
+ [ELF_E_NO_PHDR] = ELF_E_NO_PHDR_IDX,
+ [ELF_E_INVALID_OFFSET] = ELF_E_INVALID_OFFSET_IDX
};
#define nmsgidx ((int) (sizeof (msgidx) / sizeof (msgidx[0])))
diff --git a/libelf/gelf.h b/libelf/gelf.h
index 299d6c83..369a3a71 100644
--- a/libelf/gelf.h
+++ b/libelf/gelf.h
@@ -153,6 +153,9 @@ extern int gelf_update_ehdr (Elf *__elf, GElf_Ehdr *__src);
/* Create new ELF header if none exists. */
extern unsigned long int gelf_newehdr (Elf *__elf, int __class);
+/* Get section at OFFSET. */
+extern Elf_Scn *gelf_offscn (Elf *__elf, GElf_Off __offset);
+
/* Retrieve section header. */
extern GElf_Shdr *gelf_getshdr (Elf_Scn *__scn, GElf_Shdr *__dst);
diff --git a/libelf/libelf.h b/libelf/libelf.h
index 5b3dc00b..05a03412 100644
--- a/libelf/libelf.h
+++ b/libelf/libelf.h
@@ -1,5 +1,5 @@
/* Interface for libelf.
- Copyright (C) 1998, 1999, 2000, 2002, 2004 Red Hat, Inc.
+ Copyright (C) 1998, 1999, 2000, 2002, 2004, 2005 Red Hat, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -199,6 +199,11 @@ extern Elf64_Phdr *elf64_newphdr (Elf *__elf, size_t __cnt);
/* Get section at INDEX. */
extern Elf_Scn *elf_getscn (Elf *__elf, size_t __index);
+/* Get section at OFFSET. */
+extern Elf_Scn *elf32_offscn (Elf *__elf, Elf32_Off __offset);
+/* Similar bug this time the binary calls is ELFCLASS64. */
+extern Elf_Scn *elf64_offscn (Elf *__elf, Elf64_Off __offset);
+
/* Get index of section. */
extern size_t elf_ndxscn (Elf_Scn *__scn);
diff --git a/libelf/libelf.map b/libelf/libelf.map
index f416da7f..a5193b32 100644
--- a/libelf/libelf.map
+++ b/libelf/libelf.map
@@ -7,6 +7,7 @@ ELFUTILS_1.0 {
elf32_getshdr;
elf32_newehdr;
elf32_newphdr;
+ elf32_offscn;
elf32_xlatetof;
elf32_xlatetom;
elf64_checksum;
@@ -16,6 +17,7 @@ ELFUTILS_1.0 {
elf64_getshdr;
elf64_newehdr;
elf64_newphdr;
+ elf64_offscn;
elf64_xlatetof;
elf64_xlatetom;
elf_begin;
@@ -75,6 +77,7 @@ ELFUTILS_1.0 {
gelf_getversym;
gelf_newehdr;
gelf_newphdr;
+ gelf_offscn;
gelf_rawchunk;
gelf_update_dyn;
gelf_update_ehdr;
diff --git a/libelf/libelfP.h b/libelf/libelfP.h
index 100f349a..fd6f825c 100644
--- a/libelf/libelfP.h
+++ b/libelf/libelfP.h
@@ -117,6 +117,7 @@ enum
ELF_E_GROUP_NOT_REL,
ELF_E_INVALID_PHDR,
ELF_E_NO_PHDR,
+ ELF_E_INVALID_OFFSET,
/* Keep this as the last entry. */
ELF_E_NUM
};
@@ -453,6 +454,10 @@ extern Elf32_Phdr *__elf32_newphdr_internal (Elf *__elf, size_t __cnt)
attribute_hidden;
extern Elf64_Phdr *__elf64_newphdr_internal (Elf *__elf, size_t __cnt)
attribute_hidden;
+extern Elf_Scn *__elf32_offscn_internal (Elf *__elf, Elf32_Off __offset)
+ attribute_hidden;
+extern Elf_Scn *__elf64_offscn_internal (Elf *__elf, Elf64_Off __offset)
+ attribute_hidden;
extern int __elf_getshnum_internal (Elf *__elf, size_t *__dst)
attribute_hidden;
extern int __elf_getshstrndx_internal (Elf *__elf, size_t *__dst)