summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-06-11 20:25:23 +0000
committerUlrich Drepper <drepper@redhat.com>2006-06-11 20:25:23 +0000
commitcbb51e5253e05d98af8bdaf2217fed00b2e489b9 (patch)
tree200b72eb222a933df79cecc74d4e56383ad803a6
parent54f33a779527d6764b4fc4068267715a718c422c (diff)
downloadelfutils-cbb51e5253e05d98af8bdaf2217fed00b2e489b9.tar.gz
* elflint.c (check_dynamic): Fix checking value of tags which are
offsets in the string section. Make sure DT_STRTAB points to the section referenced in sh_link. * ld.c (options): Add headers. Add short option 'R' for '--rpath'.
-rw-r--r--TODO8
-rw-r--r--src/ChangeLog6
-rw-r--r--src/elflint.c57
-rw-r--r--src/ld.c78
4 files changed, 81 insertions, 68 deletions
diff --git a/TODO b/TODO
index 9eb7b6ca..b3b4441b 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,7 @@
ToDo list for elfutils -*-outline-*-
----------------------
-Time-stamp: <2005-08-29 08:58:24 drepper>
+Time-stamp: <2006-06-11 11:07:01 drepper>
* mkinstalldirs
@@ -79,12 +79,16 @@ Time-stamp: <2005-08-29 08:58:24 drepper>
The old mapping should be reused in that case. The problem is worse
for files which are not mapped read-only (archives again).
-
** size for STT_SECTION entries
The STT_SECTION entries have zero for the size but can easily get
the size of the section.
+** .eh_frame_hdr
+
+ Not implemented at all in the moment except for recognition of the option
+ itself.
+
* elflint
** additional checks
diff --git a/src/ChangeLog b/src/ChangeLog
index a4cee179..74ea2bfa 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
2006-06-11 Ulrich Drepper <drepper@redhat.com>
+ * elflint.c (check_dynamic): Fix checking value of tags which are
+ offsets in the string section. Make sure DT_STRTAB points to the
+ section referenced in sh_link.
+
+ * ld.c (options): Add headers. Add short option 'R' for '--rpath'.
+
* ld.c: Recognize --eh-frame-hdr option.
* ld.h (struct ld_state): Add eh_frame_hdr field.
* ldgeneric.c (struct unw_eh_frame_hdr): Define.
diff --git a/src/elflint.c b/src/elflint.c
index 0a415b00..b1eb5d3d 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -1513,32 +1513,42 @@ section [%2d] '%s': entry %zu: DT_PLTREL value must be DT_REL or DT_RELA\n"),
switch (dyn->d_tag)
{
size_t n;
+ case DT_STRTAB:
+ /* We require the referenced section is the same as the one
+ specified in sh_link. */
+ if (strshdr->sh_addr != dyn->d_un.d_val)
+ {
+ ERROR (gettext ("\
+section [%2d] '%s': entry %zu: pointer does not match address of section [%2d] '%s' referenced by sh_link\n"),
+ idx, section_name (ebl, idx), cnt,
+ shdr->sh_link, section_name (ebl, shdr->sh_link));
+ break;
+ }
+ goto check_addr;
+
default:
if (dyn->d_tag < DT_ADDRRNGLO || dyn->d_tag > DT_ADDRRNGHI)
/* Value is no pointer. */
break;
/* FALLTHROUGH */
- case DT_PLTGOT:
+ case DT_AUXILIARY:
+ case DT_FILTER:
+ case DT_FINI:
+ case DT_FINI_ARRAY:
case DT_HASH:
- case DT_STRTAB:
- case DT_SYMTAB:
- case DT_RELA:
case DT_INIT:
- case DT_FINI:
- case DT_SONAME:
- case DT_RPATH:
- case DT_SYMBOLIC:
- case DT_REL:
- case DT_JMPREL:
case DT_INIT_ARRAY:
- case DT_FINI_ARRAY:
- case DT_RUNPATH:
- case DT_VERSYM:
+ case DT_JMPREL:
+ case DT_PLTGOT:
+ case DT_REL:
+ case DT_RELA:
+ case DT_SYMBOLIC:
+ case DT_SYMTAB:
case DT_VERDEF:
case DT_VERNEED:
- case DT_AUXILIARY:
- case DT_FILTER:
+ case DT_VERSYM:
+ check_addr:
for (n = 0; n < ehdr->e_phnum; ++n)
{
GElf_Phdr phdr_mem;
@@ -1557,6 +1567,23 @@ section [%2d] '%s': entry %zu: %s value must point into loaded segment\n"),
ebl_dynamic_tag_name (ebl, dyn->d_tag, buf,
sizeof (buf)));
}
+ break;
+
+ case DT_NEEDED:
+ case DT_RPATH:
+ case DT_RUNPATH:
+ case DT_SONAME:
+ if (dyn->d_un.d_ptr >= strshdr->sh_size)
+ {
+ char buf[50];
+ ERROR (gettext ("\
+section [%2d] '%s': entry %zu: %s value must be valid offset in section [%2d] '%s'\n"),
+ idx, section_name (ebl, idx), cnt,
+ ebl_dynamic_tag_name (ebl, dyn->d_tag, buf,
+ sizeof (buf)),
+ shdr->sh_link, section_name (ebl, shdr->sh_link));
+ }
+ break;
}
}
diff --git a/src/ld.c b/src/ld.c
index a0d00fe2..5c20f475 100644
--- a/src/ld.c
+++ b/src/ld.c
@@ -62,7 +62,6 @@ enum
ARGP_static,
ARGP_dynamic,
ARGP_pagesize,
- ARGP_rpath,
ARGP_rpath_link,
ARGP_runpath,
ARGP_runpath_link,
@@ -83,23 +82,26 @@ enum
/* Definitions of arguments for argp functions. */
static const struct argp_option options[] =
{
- /* XXX This list will be reordered and section names will be added.
- Just not right now. */
+ { NULL, 0, NULL, 0, N_("Input File Control:"), 0 },
{ "whole-archive", ARGP_whole_archive, NULL, 0,
N_("Include whole archives in the output from now on."), 0 },
{ "no-whole-archive", ARGP_no_whole_archive, NULL, 0,
N_("Stop including the whole arhives in the output."), 0 },
+ { NULL, 'l', N_("FILE"), OPTION_HIDDEN, NULL, 0 },
+ { NULL, '(', NULL, 0, N_("Start a group."), 0 },
+ { NULL, ')', NULL, 0, N_("End a group."), 0 },
+ { NULL, 'L', N_("PATH"), 0,
+ N_("Add PATH to list of directories files are searched in."), 0 },
+ { "as-needed", ARGP_as_needed, NULL, 0,
+ N_("Only set DT_NEEDED for following dynamic libs if actually used"), 0 },
+ { "no-as-needed", ARGP_no_as_needed, NULL, 0,
+ N_("Always set DT_NEEDED for following dynamic libs"), 0 },
+ { "rpath-link", ARGP_rpath_link, "PATH", OPTION_HIDDEN, NULL, 0 },
+ { NULL, 'i', NULL, 0, N_("Ignore LD_LIBRARY_PATH environment variable."),
+ 0 },
+ { NULL, 0, NULL, 0, N_("Output File Control:"), 0 },
{ "output", 'o', N_("FILE"), 0, N_("Place output in FILE."), 0 },
-
- { NULL, 'O', N_("LEVEL"), OPTION_ARG_OPTIONAL,
- N_("Set optimization level to LEVEL."), 0 },
-
- { "verbose", 'v', NULL, 0, N_("Verbose messages."), 0 },
- { "trace", 't', NULL, 0, N_("Trace file opens."), 0 },
- { "conserve-memory", ARGP_conserve, NULL, 0,
- N_("Trade speed for less memory usage"), 0 },
-
{ NULL, 'z', "KEYWORD", OPTION_HIDDEN, NULL, 0 },
{ "-z nodefaultlib", '\0', NULL, OPTION_DOC,
N_("Object is marked to not use default search path at runtime."), 0 },
@@ -131,82 +133,56 @@ Default rules of extracting from archive; weak references are not enough."),
N_("Ignore/record dependencies on unused DSOs."), 0 },
{ "-z systemlibrary", '\0', NULL, OPTION_DOC,
N_("Generated DSO will be a system library."), 0 },
-
- { NULL, 'l', N_("FILE"), OPTION_HIDDEN, NULL, 0 },
-
- { NULL, '(', NULL, 0, N_("Start a group."), 0 },
- { NULL, ')', NULL, 0, N_("End a group."), 0 },
-
- { NULL, 'L', N_("PATH"), 0,
- N_("Add PATH to list of directories files are searched in."), 0 },
-
- { NULL, 'c', N_("FILE"), 0, N_("Use linker script in FILE."), 0 },
-
{ "entry", 'e', N_("ADDRESS"), 0, N_("Set entry point address."), 0 },
-
{ "static", ARGP_static, NULL, OPTION_HIDDEN, NULL, 0 },
{ "-B static", ARGP_static, NULL, OPTION_DOC,
N_("Do not link against shared libraries."), 0 },
{ "dynamic", ARGP_dynamic, NULL, OPTION_HIDDEN, NULL, 0 },
{ "-B dynamic", ARGP_dynamic, NULL, OPTION_DOC,
N_("Prefer linking against shared libraries."), 0 },
-
{ "export-dynamic", 'E', NULL, 0, N_("Export all dynamic symbols."), 0 },
-
{ "strip-all", 's', NULL, 0, N_("Strip all symbols."), 0 },
{ "strip-debug", 'S', NULL, 0, N_("Strip debugging symbols."), 0 },
-
{ "pagesize", ARGP_pagesize, "SIZE", 0,
N_("Assume pagesize for the target system to be SIZE."), 0 },
-
- { "rpath", ARGP_rpath, "PATH", OPTION_HIDDEN, NULL, 0 },
- { "rpath-link", ARGP_rpath_link, "PATH", OPTION_HIDDEN, NULL, 0 },
-
+ { "rpath", 'R', "PATH", OPTION_HIDDEN, NULL, 0 },
{ "runpath", ARGP_runpath, "PATH", 0, N_("Set runtime DSO search path."),
0 },
{ "runpath-link", ARGP_runpath_link, "PATH", 0,
N_("Set link time DSO search path."), 0 },
-
- { NULL, 'i', NULL, 0, N_("Ignore LD_LIBRARY_PATH environment variable."),
- 0 },
-
- { "version-script", ARGP_version_script, "FILE", 0,
- N_("Read version information from FILE."), 0 },
-
- { "emulation", 'm', "NAME", 0, N_("Set emulation to NAME."), 0 },
-
{ "shared", 'G', NULL, 0, N_("Generate dynamic shared object."), 0 },
{ NULL, 'r', NULL, 0L, N_("Generate relocatable object."), 0 },
-
{ NULL, 'B', "KEYWORD", OPTION_HIDDEN, "", 0 },
{ "-B local", 'B', NULL, OPTION_DOC,
N_("Causes symbol not assigned to a version be reduced to local."), 0 },
-
{ "gc-sections", ARGP_gc_sections, NULL, 0, N_("Remove unused sections."),
0 },
{ "no-gc-sections", ARGP_no_gc_sections, NULL, 0,
N_("Don't remove unused sections."), 0 },
-
{ "soname", 'h', "NAME", 0, N_("Set soname of shared object."), 0 },
{ "dynamic-linker", 'I', "NAME", 0, N_("Set the dynamic linker name."), 0 },
-
{ NULL, 'Q', "YN", OPTION_HIDDEN, NULL, 0 },
{ "-Q y | n", 'Q', NULL, OPTION_DOC,
N_("Add/suppress addition indentifying link-editor to .comment section"),
0 },
-
- { "as-needed", ARGP_as_needed, NULL, 0,
- N_("Only set DT_NEEDED for following dynamic libs if actually used"), 0 },
- { "no-as-needed", ARGP_no_as_needed, NULL, 0,
- N_("Always set DT_NEEDED for following dynamic libs"), 0 },
-
{ "eh-frame-hdr", ARGP_eh_frame_hdr, NULL, 0,
N_("Create .eh_frame_hdr section"), 0 },
+ { NULL, 0, NULL, 0, N_("Linker Operation Control:"), 0 },
+ { "verbose", 'v', NULL, 0, N_("Verbose messages."), 0 },
+ { "trace", 't', NULL, 0, N_("Trace file opens."), 0 },
+ { "conserve-memory", ARGP_conserve, NULL, 0,
+ N_("Trade speed for less memory usage"), 0 },
+ { NULL, 'O', N_("LEVEL"), OPTION_ARG_OPTIONAL,
+ N_("Set optimization level to LEVEL."), 0 },
+ { NULL, 'c', N_("FILE"), 0, N_("Use linker script in FILE."), 0 },
#if YYDEBUG
{ "yydebug", ARGP_yydebug, NULL, 0,
N_("Select to get parser debug information"), 0 },
#endif
+ { "version-script", ARGP_version_script, "FILE", 0,
+ N_("Read version information from FILE."), 0 },
+ { "emulation", 'm', "NAME", 0, N_("Set emulation to NAME."), 0 },
{ NULL, 0, NULL, 0, NULL, 0 }
};
@@ -610,7 +586,7 @@ parse_opt_1st (int key, char *arg,
}
break;
- case ARGP_rpath:
+ case 'R':
add_rxxpath (&ld_state.rpath, arg);
break;