* elf-bfd.h (struct elf_backend_data): Remove as_needed_cleanup.

Add notice_as_needed.
	* elf64-ppc.c (elf_backend_as_needed_cleanup): Don't define.
	(elf_backend_notice_as_needed): Define.
	(ppc64_elf_as_needed_cleanup): Rename and adjust..
	(ppc64_elf_notice_as_needed): ..to this.
	* elflink.c (_bfd_elf_notice_as_needed): New function, extracted..
	(elf_link_add_object_symbols): ..from here.
	* elfxx-target.h (elf_backend_as_needed_cleanup): Don't define.
	(elf_backend_notice_as_needed): Define..
	(elfNN_bed): ..and use here.
This commit is contained in:
Alan Modra 2013-08-27 01:06:43 +00:00
parent ce4ea2bb17
commit e5034e59e0
5 changed files with 52 additions and 25 deletions

View File

@ -1,3 +1,17 @@
2013-08-27 Alan Modra <amodra@gmail.com>
* elf-bfd.h (struct elf_backend_data): Remove as_needed_cleanup.
Add notice_as_needed.
* elf64-ppc.c (elf_backend_as_needed_cleanup): Don't define.
(elf_backend_notice_as_needed): Define.
(ppc64_elf_as_needed_cleanup): Rename and adjust..
(ppc64_elf_notice_as_needed): ..to this.
* elflink.c (_bfd_elf_notice_as_needed): New function, extracted..
(elf_link_add_object_symbols): ..from here.
* elfxx-target.h (elf_backend_as_needed_cleanup): Don't define.
(elf_backend_notice_as_needed): Define..
(elfNN_bed): ..and use here.
2013-08-26 Roland McGrath <mcgrathr@google.com>
* archures.c (bfd_mach_i386_nacl, bfd_mach_i386_i386_nacl): New macros.

View File

@ -881,12 +881,12 @@ struct elf_backend_data
bfd_boolean (*check_directives)
(bfd *abfd, struct bfd_link_info *info);
/* The AS_NEEDED_CLEANUP function is called once per --as-needed
input file that was not needed by the add_symbols phase of the
ELF backend linker. The function must undo any target specific
changes in the symbol hash table. */
bfd_boolean (*as_needed_cleanup)
(bfd *abfd, struct bfd_link_info *info);
/* The NOTICE_AS_NEEDED function is called as the linker is about to
handle an as-needed lib (ACT = notice_as_needed), and after the
linker has decided to keep the lib (ACT = notice_needed) or when
the lib is not needed (ACT = notice_not_needed). */
bfd_boolean (*notice_as_needed)
(bfd *abfd, struct bfd_link_info *info, enum notice_asneeded_action act);
/* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
linker for every symbol which is defined by a dynamic object and
@ -2139,6 +2139,8 @@ extern bfd_boolean _bfd_elf_default_relocs_compatible
extern bfd_boolean _bfd_elf_relocs_compatible
(const bfd_target *, const bfd_target *);
extern bfd_boolean _bfd_elf_notice_as_needed
(bfd *, struct bfd_link_info *, enum notice_asneeded_action);
extern struct elf_link_hash_entry *_bfd_elf_archive_symbol_lookup
(bfd *, struct bfd_link_info *, const char *);

View File

@ -96,7 +96,7 @@ static bfd_vma opd_entry_value
#define elf_backend_copy_indirect_symbol ppc64_elf_copy_indirect_symbol
#define elf_backend_add_symbol_hook ppc64_elf_add_symbol_hook
#define elf_backend_check_directives ppc64_elf_process_dot_syms
#define elf_backend_as_needed_cleanup ppc64_elf_as_needed_cleanup
#define elf_backend_notice_as_needed ppc64_elf_notice_as_needed
#define elf_backend_archive_symbol_lookup ppc64_elf_archive_symbol_lookup
#define elf_backend_check_relocs ppc64_elf_check_relocs
#define elf_backend_gc_keep ppc64_elf_gc_keep
@ -4806,16 +4806,20 @@ ppc64_elf_process_dot_syms (bfd *ibfd, struct bfd_link_info *info)
not to be needed. */
static bfd_boolean
ppc64_elf_as_needed_cleanup (bfd *ibfd ATTRIBUTE_UNUSED,
struct bfd_link_info *info)
ppc64_elf_notice_as_needed (bfd *ibfd,
struct bfd_link_info *info,
enum notice_asneeded_action act)
{
struct ppc_link_hash_table *htab = ppc_hash_table (info);
if (act == notice_not_needed)
{
struct ppc_link_hash_table *htab = ppc_hash_table (info);
if (htab == NULL)
return FALSE;
if (htab == NULL)
return FALSE;
htab->dot_syms = NULL;
return TRUE;
htab->dot_syms = NULL;
}
return _bfd_elf_notice_as_needed (ibfd, info, act);
}
/* If --just-symbols against a final linked binary, then assume we need

View File

@ -3309,6 +3309,18 @@ _bfd_elf_relocs_compatible (const bfd_target *input,
return ibed->relocs_compatible == obed->relocs_compatible;
}
/* Make a special call to the linker "notice" function to tell it that
we are about to handle an as-needed lib, or have finished
processing the lib. */
bfd_boolean
_bfd_elf_notice_as_needed (bfd *ibfd,
struct bfd_link_info *info,
enum notice_asneeded_action act)
{
return (*info->callbacks->notice) (info, NULL, ibfd, NULL, act, 0, NULL);
}
/* Add symbols from an ELF object file to the linker hash table. */
static bfd_boolean
@ -3766,8 +3778,7 @@ error_free_dyn:
/* Make a special call to the linker "notice" function to
tell it that we are about to handle an as-needed lib. */
if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
notice_as_needed, 0, NULL))
if (!(*bed->notice_as_needed) (abfd, info, notice_as_needed))
goto error_free_vers;
/* Clone the symbol table. Remember some pointers into the
@ -4461,8 +4472,6 @@ error_free_dyn:
unsigned int i;
/* Restore the symbol table. */
if (bed->as_needed_cleanup)
(*bed->as_needed_cleanup) (abfd, info);
old_ent = (char *) old_tab + tabsize;
memset (elf_sym_hashes (abfd), 0,
extsymcount * sizeof (struct elf_link_hash_entry *));
@ -4524,8 +4533,7 @@ error_free_dyn:
/* Make a special call to the linker "notice" function to
tell it that symbols added for crefs may need to be removed. */
if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
notice_not_needed, 0, NULL))
if (!(*bed->notice_as_needed) (abfd, info, notice_not_needed))
goto error_free_vers;
free (old_tab);
@ -4538,8 +4546,7 @@ error_free_dyn:
if (old_tab != NULL)
{
if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
notice_needed, 0, NULL))
if (!(*bed->notice_as_needed) (abfd, info, notice_needed))
goto error_free_vers;
free (old_tab);
old_tab = NULL;

View File

@ -424,8 +424,8 @@
#ifndef elf_backend_check_directives
#define elf_backend_check_directives 0
#endif
#ifndef elf_backend_as_needed_cleanup
#define elf_backend_as_needed_cleanup 0
#ifndef elf_backend_notice_as_needed
#define elf_backend_notice_as_needed _bfd_elf_notice_as_needed
#endif
#ifndef elf_backend_adjust_dynamic_symbol
#define elf_backend_adjust_dynamic_symbol 0
@ -705,7 +705,7 @@ static struct elf_backend_data elfNN_bed =
elf_backend_relocs_compatible,
elf_backend_check_relocs,
elf_backend_check_directives,
elf_backend_as_needed_cleanup,
elf_backend_notice_as_needed,
elf_backend_adjust_dynamic_symbol,
elf_backend_always_size_sections,
elf_backend_size_dynamic_sections,