for PLT entries if there is no local definition.
* ld.c (parse_option): Handle -z ignore like --as-needed and
-z record like --no-as-needed.
* ld.h (struct ld_state): Remove ignore_unused_dsos field.
* ldgeneric.c (new_generated_scn): Always compute ndt_needed by
looping over DSOs. When deciding about adding DT_NEEDED entries
use ->as_needed instead of ignore_unused_dsos.
/* Interfaces for libdw.
Copyright (C) 2002, 2004, 2005, 2006 Red Hat, Inc.
This file is part of Red Hat elfutils.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Red Hat elfutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
/* Internal interfaces for libelf.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 Red Hat, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 Red Hat, Inc.
This file is part of Red Hat elfutils.
Contributed by Ulrich Drepper <drepper@redhat.com>, 1998.
/* We often have to update a flag iff a value changed. Make this
- convenient. */
-#define update_if_changed(var, exp, flag) \
+ convenient. None of the parameters must have a side effect. */
+#ifdef __GNUC__
+# define update_if_changed(var, exp, flag) \
do { \
__typeof__ (var) *_var = &(var); \
__typeof__ (exp) _exp = (exp); \
(flag) |= ELF_F_DIRTY; \
} \
} while (0)
+#else
+# define update_if_changed(var, exp, flag) \
+ do { \
+ if ((var) != (exp)) \
+ { \
+ (var) = (exp); \
+ (flag) |= ELF_F_DIRTY; \
+ } \
+ } while (0)
+#endif
#endif /* libelfP.h */
+2006-06-09 Ulrich Drepper <drepper@redhat.com>
+
+ * i386_ld.c (elf_i386_finalize_plt): Don't change symbol table entries
+ for PLT entries if there is no local definition.
+
+ * ld.c (parse_option): Handle -z ignore like --as-needed and
+ -z record like --no-as-needed.
+ * ld.h (struct ld_state): Remove ignore_unused_dsos field.
+ * ldgeneric.c (new_generated_scn): Always compute ndt_needed by
+ looping over DSOs. When deciding about adding DT_NEEDED entries
+ use ->as_needed instead of ignore_unused_dsos.
+
2006-05-31 Ulrich Drepper <drepper@redhat.com>
* ld.c: Recognize --as-needed and --no-as-needed options.
combinations.
(mark_as_needed): Fix loop.
-2006-05-28 Ulrich Drepper <drepper@redhat.com>
-
- * addr2line.c (print_dwarf_function): Use unsigned type for lineno
- and colno.
-
2006-05-27 Ulrich Drepper <drepper@redhat.com>
* readelf.c (handle_relocs_rela): Better notations for addon value.
&attr_mem), &val) == 0)
{
const char *file = dwarf_filesrc (files, val, NULL, NULL);
- unsigned int lineno = 0;
- unsigned int colno = 0;
+ int lineno = 0, colno = 0;
if (dwarf_formudata (dwarf_attr (&scopes[i],
DW_AT_call_line,
&attr_mem), &val) == 0)
-/* Copyright (C) 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2001.
/* Point the GOT entry at the PLT entry, after the initial jmp. */
((Elf32_Word *) data->d_buf)[3 + cnt] = pltentryaddr + 6;
- /* The value of the symbol is the address of the corresponding PLT
- entry. Store the address, also for the normal symbol table if
- this is necessary. */
- ((Elf32_Sym *) dynsymdata->d_buf)[1 + cnt].st_value = pltentryaddr;
- if (symdata != NULL)
- ((Elf32_Sym *) symdata->d_buf)[nsym - statep->nplt + cnt].st_value
- = pltentryaddr;
+ /* If the symbol is defined, adjust the address. */
+ if (((Elf32_Sym *) dynsymdata->d_buf)[1 + cnt].st_shndx != SHN_UNDEF)
+ {
+ /* The value of the symbol is the address of the corresponding PLT
+ entry. Store the address, also for the normal symbol table if
+ this is necessary. */
+ ((Elf32_Sym *) dynsymdata->d_buf)[1 + cnt].st_value = pltentryaddr;
+
+ if (symdata != NULL)
+ ((Elf32_Sym *) symdata->d_buf)[nsym - statep->nplt + cnt].st_value
+ = pltentryaddr;
+ }
}
/* Create the .plt section. */
&& ld_state.file_type == dso_file_type)
ld_state.dt_flags_1 |= DF_1_NOOPEN;
else if (strcmp (arg, "ignore") == 0)
- ld_state.ignore_unused_dsos = true;
+ ld_state.as_needed = true;
else if (strcmp (arg, "record") == 0)
- ld_state.ignore_unused_dsos = false;
+ ld_state.as_needed = false;
else if (strcmp (arg, "systemlibrary") == 0)
ld_state.is_system_library = true;
else if (strcmp (arg, "allextract") != 0
/* Lazy-loading state for dependencies. */
bool lazyload;
- /* True is DSOs which are not used in the linking process are not
- recorded. */
- bool ignore_unused_dsos;
-
/* True if in executables all global symbols should be exported in
the dynamic symbol table. */
program header. */
if (dynamically_linked_p ())
{
- int ndt_needed;
/* Use any versioning (defined or required)? */
bool use_versioning = false;
/* Use version requirements? */
new_generated_scn (scn_dot_hash, ".hash", SHT_HASH, SHF_ALLOC,
sizeof (Elf32_Word), sizeof (Elf32_Word));
- /* By default we add all DSOs provided on the command line. If
- the user added '-z ignore' to the command line we only add
- those which are actually used. */
- ndt_needed = ld_state.ignore_unused_dsos ? 0 : ld_state.ndsofiles;
-
/* Create the section associated with the PLT if necessary. */
if (ld_state.nplt > 0)
{
new_generated_scn (scn_dot_version_r, ".gnu.version_r",
SHT_GNU_verneed, SHF_ALLOC, 0,
xelf_fsize (ld_state.outelf, ELF_T_WORD, 1));
+ }
- /* Now count the used DSOs since this is what the user
- wants. */
- ndt_needed = 0;
- if (ld_state.ndsofiles > 0)
- {
- struct usedfiles *frunp = ld_state.dsofiles;
+ /* Now count the used DSOs since this is what the user
+ wants. */
+ int ndt_needed = 0;
+ if (ld_state.ndsofiles > 0)
+ {
+ struct usedfiles *frunp = ld_state.dsofiles;
- do
- if (! ld_state.ignore_unused_dsos || frunp->used)
- {
- ++ndt_needed;
- if (frunp->lazyload)
- /* We have to create another dynamic section
- entry for the DT_POSFLAG_1 entry.
-
- XXX Once more functionality than the
- lazyloading flag are suppported the test
- must be extended. */
- ++ndt_needed;
- }
- while ((frunp = frunp->next) != ld_state.dsofiles);
- }
+ do
+ if (! frunp->as_needed || frunp->used)
+ {
+ ++ndt_needed;
+ if (frunp->lazyload)
+ /* We have to create another dynamic section
+ entry for the DT_POSFLAG_1 entry.
+
+ XXX Once more functionality than the lazyloading
+ flag are suppported the test must be
+ extended. */
+ ++ndt_needed;
+ }
+ while ((frunp = frunp->next) != ld_state.dsofiles);
}
if (use_versioning)
struct usedfiles *frunp = ld_state.dsofiles;
do
- if (! ld_state.ignore_unused_dsos || frunp->used)
+ if (! frunp->as_needed || frunp->used)
frunp->sonameent = ebl_strtabadd (dynstrtab, frunp->soname,
0);
while ((frunp = frunp->next) != ld_state.dsofiles);
if (symstrent[cnt] != NULL)
{
XElf_Sym_vardef (sym);
- size_t hashidx;
size_t dynidx = ndxtosym[cnt]->outdynsymidx;
#if NATIVE_ELF != 0
(void) xelf_update_sym (dynsymdata, dynidx, sym);
/* Add to the hash table. */
- hashidx = hashcodes[dynidx] % nbucket;
+ size_t hashidx = hashcodes[dynidx] % nbucket;
if (bucket[hashidx] == 0)
bucket[hashidx] = dynidx;
else
strtab_ent = ebl_strtabadd (ld_state.shstrtab, ".strtab", 8);
/* At this point we would have to test for failures in the
allocation. But we skip this. First, the problem will be caught
- latter when doing more allocations for the section header table.
+ later when doing more allocations for the section header table.
Even if this would not be the case all that would happen is that
the section names are empty. The binary would still be usable if
it is an executable or a DSO. Not adding the test here saves
groups = ld_state.groups;
while (groups != NULL)
{
- Elf_Scn *scn;
- struct scngroup *oldp;
- Elf32_Word si;
-
- scn = elf_getscn (ld_state.outelf, groups->outscnidx);
+ Elf_Scn *scn = elf_getscn (ld_state.outelf, groups->outscnidx);
xelf_getshdr (scn, shdr);
assert (shdr != NULL);
shdr->sh_entsize = sizeof (Elf32_Word);
/* Determine the index for the signature symbol. */
- si = groups->symbol->file->symindirect[groups->symbol->symidx];
+ Elf32_Word si
+ = groups->symbol->file->symindirect[groups->symbol->symidx];
if (si == 0)
{
assert (groups->symbol->file->symref[groups->symbol->symidx]
(void) xelf_update_shdr (scn, shdr);
- oldp = groups;
+ struct scngroup *oldp = groups;
groups = groups->next;
free (oldp);
}
(void) xelf_update_phdr (ld_state.outelf, 0, phdr);
- /* Adjust the addresses in the addresses of the symbol according
- to the load addresses of the sections. */
+ /* Adjust the addresses in the address fields of the symbol
+ records according to the load addresses of the sections. */
if (ld_state.need_symtab)
for (cnt = 1; cnt < nsym; ++cnt)
{
struct usedfiles *runp = ld_state.dsofiles->next;
do
- if (! ld_state.ignore_unused_dsos || runp->used)
+ if (runp->used || !runp->as_needed)
{
/* Add the position-dependent flag if necessary. */
if (runp->lazyload)