From: Alan Modra Date: Sun, 29 May 2011 04:51:51 +0000 (+0000) Subject: PR 12365 X-Git-Tag: binutils-2_21_1~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=467f078508f8fa2613f722d1f9145e7765899431;p=thirdparty%2Fbinutils-gdb.git PR 12365 PR 12613 PR 12632 PR 12739 PR 12753 PR 12760 PR 12763 Apply fix from mainline along with assorted other small fixes. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index bcc02f3bf13..2cb0a7fa61b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,112 @@ +2011-05-29 Alan Modra + + Apply from mainline + 2011-05-26 Alan Modra + * elf-bfd.h (SYMBOL_REFERENCES_LOCAL): Remove most of comment. + * elflink.c (_bfd_elf_symbol_refs_local_p): Expand + local_protected comment. + + 2011-05-23 Alan Modra + PR 12763 + * elf.c (assign_file_positions_for_load_sections): Set sh_offset for + .tbss, and page align same for all SHT_NOBITS sections. + + 2011-05-23 Nick Clifton + * elf-m10300.c (mn10300_elf_mkobject): New function. + (bfd_elf32_mkobject): Define. + + 2011-05-21 Alan Modra + PR 12763 + * elf.c (_bfd_elf_make_section_from_shdr): Set up TLS section LMAs + from PT_TLS header. + (_bfd_elf_map_sections_to_segments): Don't create a final PT_LOAD + segment if just for .tbss. + (assign_file_positions_for_load_sections): Don't report "can't + allocate in segment" errors for .tbss. + (assign_file_positions_for_non_load_sections): Don't set p_filesz + from SHT_NOBITS section filepos. + + 2011-05-17 Alan Modra + PR ld/12760 + * coff-aux.c (coff_m68k_aux_link_add_one_symbol): Adjust "notice" call. + * elflink.c (elf_link_add_object_symbols): Likewise. + * linker.c (_bfd_generic_link_add_one_symbol): Likewise. + + 2011-05-16 Alan Modra + * linker.c (_bfd_generic_link_add_one_symbol): Don't init u.undef.weak. + + 2011-05-12 Jan Kratochvil + * config.in: Regenerated. + * configure: Regenerated. + * configure.in: New tests for HAVE_PRPSINFO_T_PR_PID, + HAVE_PRPSINFO32_T_PR_PID, HAVE_PSINFO_T_PR_PID and + HAVE_PSINFO32_T_PR_PID. + * elf.c (elfcore_grok_psinfo): Protect reading psinfo.pr_pid by + HAVE_PRPSINFO_T_PR_PID, HAVE_PRPSINFO32_T_PR_PID, HAVE_PSINFO_T_PR_PID + and HAVE_PSINFO32_T_PR_PID. + * hosts/x86-64linux.h (HAVE_PRPSINFO32_T_PR_PID): New redefinition. + + 2011-05-10 Jan Kratochvil + * elf.c (elfcore_grok_psinfo): Initialize CORE_PID for both native and + 32bit psinfo. + * elf32-ppc.c (ppc_elf_grok_psinfo): Initialize core_pid. + * elf64-ppc.c (ppc64_elf_grok_psinfo): Likewise. + + 2011-05-07 Dave Korn + PR ld/12365 + * cofflink.c (bfd_coff_link_input_bfd): Check for and warn about + references to symbols defined in discarded sections. + + 2011-05-07 Dave Korn + PR ld/12365 + * coffgen.c (coff_write_symbol): Assume input section is its own + output section if output_section member not set. + (coff_write_alien_symbol): Likewise. + + 2011-05-07 Anders Kaseorg + PR 12739 + * libbfd.c (bfd_get_8, bfd_get_signed_8): Use const cast. + * bfd-in2.h: Regenerate. + + 2011-04-28 Tom Tromey + * bfdio.c (memory_bstat): Pass correct size to memset. + + 2011-04-20 Alan Modra + * libbfd.c (bfd_log2): Do return rounded up value. + * elflink.c (bfd_elf_size_dynsym_hash_dynstr): Replace bfd_log2 + call with expanded old round down version of the function. + * archive.c (_bfd_get_elt_at_filepos): Don't release n_nfd. + * elflink.c (elf_link_add_object_symbols): Delete redundant code. + + 2011-04-09 Kai Tietz + * peXXigen.c (_bfd_XXi_final_link_postscripte): Sort pdata in temporary + buffer and use rawsize for sorting. + * coffcode.h (coff_compute_section_file_positions): Set rawsize + before doing alignment. + + 2011-04-07 Cary Coutant + * dwarf2.c (scan_unit_for_symbols): Check for DW_AT_specification. + + 2011-03-03 Michael Snyder + * aoutx.h (aout_final_link): Use sizeof int not sizeof int*. + (aout_link_write_other_symbol): Missing break statement. + + 2011-02-14 Mike Frysinger + * elflink.c (bfd_elf_size_dynamic_sections): Add + bfd_get_symbol_leading_char to the start of newname. + + 2011-01-18 Pierre Muller + Fix compilation for mingw64. + * coffcode.h (coff_slurp_symbol_table): Add intptr_t intermediate + typecast to avoid warning. + * elf32-rx.c: Add "bfd_stdint.h" include required for int32_t type + usage. + * elfxx-ia64.c (elfNN_ia64_relax_br): Use intptr_t typeacast instead + of long for pointer to avoid warning. + (elfNN_ia64_relax_brl): Idem. + (elfNN_ia64_install_value): Idem. + * vms-alpha.c (_bfd_vms_slurp_etir): Idem. + 2012-05-25 H.J. Lu Backport from mainline diff --git a/bfd/aoutx.h b/bfd/aoutx.h index 7ca221ecd6d..ec0bdf0326a 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -3637,6 +3637,7 @@ aout_link_write_other_symbol (struct aout_link_hash_entry *h, void * data) case bfd_link_hash_undefweak: type = N_WEAKU; val = 0; + break; case bfd_link_hash_indirect: /* We ignore these symbols, since the indirected symbol is already in the hash table. */ @@ -5448,7 +5449,7 @@ NAME (aout, final_link) (bfd *abfd, /* Allocate buffers to hold section contents and relocs. */ aout_info.contents = (bfd_byte *) bfd_malloc (max_contents_size); aout_info.relocs = bfd_malloc (max_relocs_size); - aout_info.symbol_map = (int *) bfd_malloc (max_sym_count * sizeof (int *)); + aout_info.symbol_map = (int *) bfd_malloc (max_sym_count * sizeof (int)); aout_info.output_syms = (struct external_nlist *) bfd_malloc ((max_sym_count + 1) * sizeof (struct external_nlist)); if ((aout_info.contents == NULL && max_contents_size != 0) diff --git a/bfd/archive.c b/bfd/archive.c index 74c28842574..64a3cee964e 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -661,10 +661,6 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos) if (_bfd_add_bfd_to_archive_cache (archive, filepos, n_nfd)) return n_nfd; - /* Huh? */ - /* FIXME: n_nfd isn't allocated in the archive's memory pool. - If we reach this point, I think bfd_release will abort. */ - bfd_release (archive, n_nfd); bfd_release (archive, new_areldata); return NULL; } diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 0907784a409..59b1b8f6983 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1029,9 +1029,9 @@ bfd_boolean bfd_fill_in_gnu_debuglink_section #define bfd_put_signed_8 \ bfd_put_8 #define bfd_get_8(abfd, ptr) \ - (*(unsigned char *) (ptr) & 0xff) + (*(const unsigned char *) (ptr) & 0xff) #define bfd_get_signed_8(abfd, ptr) \ - (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80) + (((*(const unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80) #define bfd_put_16(abfd, val, ptr) \ BFD_SEND (abfd, bfd_putx16, ((val),(ptr))) diff --git a/bfd/bfdio.c b/bfd/bfdio.c index ce92781d505..dab8e88fb23 100644 --- a/bfd/bfdio.c +++ b/bfd/bfdio.c @@ -1,7 +1,7 @@ /* Low-level I/O routines for BFDs. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011 Free Software Foundation, Inc. Written by Cygnus Support. @@ -577,7 +577,7 @@ memory_bstat (bfd *abfd, struct stat *statbuf) { struct bfd_in_memory *bim = (struct bfd_in_memory *) abfd->iostream; - memset (statbuf, 0, sizeof (statbuf)); + memset (statbuf, 0, sizeof (*statbuf)); statbuf->st_size = bim->size; return 0; diff --git a/bfd/coff-aux.c b/bfd/coff-aux.c index 052892445b3..fbffbed46d8 100644 --- a/bfd/coff-aux.c +++ b/bfd/coff-aux.c @@ -105,7 +105,8 @@ coff_m68k_aux_link_add_one_symbol (info, abfd, name, flags, section, value, && (bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE) != (struct bfd_hash_entry *) NULL)) { - if (! (*info->callbacks->notice) (info, h, abfd, section, value)) + if (! (*info->callbacks->notice) (info, h, abfd, section, value, + flags, string)) return FALSE; } diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 70f98512f9a..f1829a13ff1 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -3295,6 +3295,8 @@ coff_compute_section_file_positions (bfd * abfd) if (!(current->flags & SEC_HAS_CONTENTS)) continue; + current->rawsize = current->size; + #ifdef COFF_IMAGE_WITH_PE /* Make sure we skip empty sections in a PE image. */ if (current->size == 0) @@ -3361,7 +3363,7 @@ coff_compute_section_file_positions (bfd * abfd) #ifdef COFF_IMAGE_WITH_PE /* Set the padded size. */ - current->size = (current->size + page_size -1) & -page_size; + current->size = (current->size + page_size - 1) & -page_size; #endif sofar += current->size; @@ -4852,7 +4854,7 @@ coff_slurp_symbol_table (bfd * abfd) to the symbol instead of the index. FIXME: This should use a union. */ src->u.syment.n_value = - (long) (native_symbols + src->u.syment.n_value); + (long) (intptr_t) (native_symbols + src->u.syment.n_value); dst->symbol.value = src->u.syment.n_value; src->fix_value = 1; break; diff --git a/bfd/coffgen.c b/bfd/coffgen.c index fc82d57dd73..b0c2c62f187 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -915,6 +915,9 @@ coff_write_symbol (bfd *abfd, unsigned int numaux = native->u.syment.n_numaux; int type = native->u.syment.n_type; int n_sclass = (int) native->u.syment.n_sclass; + asection *output_section = symbol->section->output_section + ? symbol->section->output_section + : symbol->section; void * buf; bfd_size_type symesz; @@ -933,7 +936,7 @@ coff_write_symbol (bfd *abfd, else native->u.syment.n_scnum = - symbol->section->output_section->target_index; + output_section->target_index; coff_fix_symbol_name (abfd, symbol, native, string_size_p, debug_string_section_p, debug_string_size_p); @@ -990,6 +993,9 @@ coff_write_alien_symbol (bfd *abfd, { combined_entry_type *native; combined_entry_type dummy; + asection *output_section = symbol->section->output_section + ? symbol->section->output_section + : symbol->section; native = &dummy; native->u.syment.n_type = T_NULL; @@ -1015,12 +1021,11 @@ coff_write_alien_symbol (bfd *abfd, } else { - native->u.syment.n_scnum = - symbol->section->output_section->target_index; + native->u.syment.n_scnum = output_section->target_index; native->u.syment.n_value = (symbol->value + symbol->section->output_offset); if (! obj_pe (abfd)) - native->u.syment.n_value += symbol->section->output_section->vma; + native->u.syment.n_value += output_section->vma; /* Copy the any flags from the file header into the symbol. FIXME: Why? */ diff --git a/bfd/cofflink.c b/bfd/cofflink.c index 33de7fe3cc8..fdfab1de48f 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -2365,6 +2365,35 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *finfo, bfd *input_bfd) if (internal_relocs == NULL) return FALSE; + /* Run through the relocs looking for relocs against symbols + coming from discarded sections and complain about them. */ + irel = internal_relocs; + for (; irel < &internal_relocs[o->reloc_count]; irel++) + { + struct coff_link_hash_entry *h; + asection *ps = NULL; + long symndx = irel->r_symndx; + if (symndx < 0) + continue; + h = obj_coff_sym_hashes (input_bfd)[symndx]; + if (h == NULL) + continue; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct coff_link_hash_entry *) h->root.u.i.link; + if (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + ps = h->root.u.def.section; + if (ps == NULL) + continue; + /* Complain if definition comes from an excluded section. */ + if (ps->flags & SEC_EXCLUDE) + (*finfo->info->callbacks->einfo) + (_("%X`%s' referenced in section `%A' of %B: " + "defined in discarded section `%A' of %B\n"), + h->root.root.string, o, input_bfd, ps, ps->owner); + } + /* Call processor specific code to relocate the section contents. */ if (! bfd_coff_relocate_section (output_bfd, finfo->info, diff --git a/bfd/config.in b/bfd/config.in index b0b97a27f49..98157e13e0b 100644 --- a/bfd/config.in +++ b/bfd/config.in @@ -144,9 +144,15 @@ /* Define if has prpsinfo32_t. */ #undef HAVE_PRPSINFO32_T +/* Define if has prpsinfo32_t.pr_pid. */ +#undef HAVE_PRPSINFO32_T_PR_PID + /* Define if has prpsinfo_t. */ #undef HAVE_PRPSINFO_T +/* Define if has prpsinfo_t.pr_pid. */ +#undef HAVE_PRPSINFO_T_PR_PID + /* Define if has prstatus32_t. */ #undef HAVE_PRSTATUS32_T @@ -162,9 +168,15 @@ /* Define if has psinfo32_t. */ #undef HAVE_PSINFO32_T +/* Define if has psinfo32_t.pr_pid. */ +#undef HAVE_PSINFO32_T_PR_PID + /* Define if has psinfo_t. */ #undef HAVE_PSINFO_T +/* Define if has psinfo_t.pr_pid. */ +#undef HAVE_PSINFO_T_PR_PID + /* Define if has pstatus32_t. */ #undef HAVE_PSTATUS32_T diff --git a/bfd/configure b/bfd/configure index 301def925a6..63687e5d10c 100755 --- a/bfd/configure +++ b/bfd/configure @@ -14387,6 +14387,43 @@ $as_echo "#define HAVE_PRPSINFO_T 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_prpsinfo_t" >&5 $as_echo "$bfd_cv_have_sys_procfs_type_prpsinfo_t" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for prpsinfo_t.pr_pid in sys/procfs.h" >&5 +$as_echo_n "checking for prpsinfo_t.pr_pid in sys/procfs.h... " >&6; } + if test "${bfd_cv_have_sys_procfs_type_member_prpsinfo_t_pr_pid+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define _SYSCALL32 +/* Needed for new procfs interface on sparc-solaris. */ +#define _STRUCTURED_PROC 1 +#include +int +main () +{ +prpsinfo_t avar; void* aref = (void*) &avar.pr_pid + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bfd_cv_have_sys_procfs_type_member_prpsinfo_t_pr_pid=yes +else + bfd_cv_have_sys_procfs_type_member_prpsinfo_t_pr_pid=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + if test $bfd_cv_have_sys_procfs_type_member_prpsinfo_t_pr_pid = yes; then + +$as_echo "#define HAVE_PRPSINFO_T_PR_PID 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_member_prpsinfo_t_pr_pid" >&5 +$as_echo "$bfd_cv_have_sys_procfs_type_member_prpsinfo_t_pr_pid" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for prpsinfo32_t in sys/procfs.h" >&5 $as_echo_n "checking for prpsinfo32_t in sys/procfs.h... " >&6; } if test "${bfd_cv_have_sys_procfs_type_prpsinfo32_t+set}" = set; then : @@ -14424,6 +14461,43 @@ $as_echo "#define HAVE_PRPSINFO32_T 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_prpsinfo32_t" >&5 $as_echo "$bfd_cv_have_sys_procfs_type_prpsinfo32_t" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for prpsinfo32_t.pr_pid in sys/procfs.h" >&5 +$as_echo_n "checking for prpsinfo32_t.pr_pid in sys/procfs.h... " >&6; } + if test "${bfd_cv_have_sys_procfs_type_member_prpsinfo32_t_pr_pid+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define _SYSCALL32 +/* Needed for new procfs interface on sparc-solaris. */ +#define _STRUCTURED_PROC 1 +#include +int +main () +{ +prpsinfo32_t avar; void* aref = (void*) &avar.pr_pid + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bfd_cv_have_sys_procfs_type_member_prpsinfo32_t_pr_pid=yes +else + bfd_cv_have_sys_procfs_type_member_prpsinfo32_t_pr_pid=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + if test $bfd_cv_have_sys_procfs_type_member_prpsinfo32_t_pr_pid = yes; then + +$as_echo "#define HAVE_PRPSINFO32_T_PR_PID 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_member_prpsinfo32_t_pr_pid" >&5 +$as_echo "$bfd_cv_have_sys_procfs_type_member_prpsinfo32_t_pr_pid" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for psinfo_t in sys/procfs.h" >&5 $as_echo_n "checking for psinfo_t in sys/procfs.h... " >&6; } if test "${bfd_cv_have_sys_procfs_type_psinfo_t+set}" = set; then : @@ -14461,6 +14535,43 @@ $as_echo "#define HAVE_PSINFO_T 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_psinfo_t" >&5 $as_echo "$bfd_cv_have_sys_procfs_type_psinfo_t" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for psinfo_t.pr_pid in sys/procfs.h" >&5 +$as_echo_n "checking for psinfo_t.pr_pid in sys/procfs.h... " >&6; } + if test "${bfd_cv_have_sys_procfs_type_member_psinfo_t_pr_pid+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define _SYSCALL32 +/* Needed for new procfs interface on sparc-solaris. */ +#define _STRUCTURED_PROC 1 +#include +int +main () +{ +psinfo_t avar; void* aref = (void*) &avar.pr_pid + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bfd_cv_have_sys_procfs_type_member_psinfo_t_pr_pid=yes +else + bfd_cv_have_sys_procfs_type_member_psinfo_t_pr_pid=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + if test $bfd_cv_have_sys_procfs_type_member_psinfo_t_pr_pid = yes; then + +$as_echo "#define HAVE_PSINFO_T_PR_PID 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_member_psinfo_t_pr_pid" >&5 +$as_echo "$bfd_cv_have_sys_procfs_type_member_psinfo_t_pr_pid" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for psinfo32_t in sys/procfs.h" >&5 $as_echo_n "checking for psinfo32_t in sys/procfs.h... " >&6; } if test "${bfd_cv_have_sys_procfs_type_psinfo32_t+set}" = set; then : @@ -14498,6 +14609,43 @@ $as_echo "#define HAVE_PSINFO32_T 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_psinfo32_t" >&5 $as_echo "$bfd_cv_have_sys_procfs_type_psinfo32_t" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for psinfo32_t.pr_pid in sys/procfs.h" >&5 +$as_echo_n "checking for psinfo32_t.pr_pid in sys/procfs.h... " >&6; } + if test "${bfd_cv_have_sys_procfs_type_member_psinfo32_t_pr_pid+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define _SYSCALL32 +/* Needed for new procfs interface on sparc-solaris. */ +#define _STRUCTURED_PROC 1 +#include +int +main () +{ +psinfo32_t avar; void* aref = (void*) &avar.pr_pid + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bfd_cv_have_sys_procfs_type_member_psinfo32_t_pr_pid=yes +else + bfd_cv_have_sys_procfs_type_member_psinfo32_t_pr_pid=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + if test $bfd_cv_have_sys_procfs_type_member_psinfo32_t_pr_pid = yes; then + +$as_echo "#define HAVE_PSINFO32_T_PR_PID 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_member_psinfo32_t_pr_pid" >&5 +$as_echo "$bfd_cv_have_sys_procfs_type_member_psinfo32_t_pr_pid" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lwpstatus_t in sys/procfs.h" >&5 $as_echo_n "checking for lwpstatus_t in sys/procfs.h... " >&6; } if test "${bfd_cv_have_sys_procfs_type_lwpstatus_t+set}" = set; then : diff --git a/bfd/configure.in b/bfd/configure.in index 4076c6ef0a6..06358104760 100644 --- a/bfd/configure.in +++ b/bfd/configure.in @@ -488,9 +488,13 @@ changequote([,])dnl BFD_HAVE_SYS_PROCFS_TYPE(pxstatus_t) BFD_HAVE_SYS_PROCFS_TYPE(pstatus32_t) BFD_HAVE_SYS_PROCFS_TYPE(prpsinfo_t) + BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(prpsinfo_t, pr_pid) BFD_HAVE_SYS_PROCFS_TYPE(prpsinfo32_t) + BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(prpsinfo32_t, pr_pid) BFD_HAVE_SYS_PROCFS_TYPE(psinfo_t) + BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(psinfo_t, pr_pid) BFD_HAVE_SYS_PROCFS_TYPE(psinfo32_t) + BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(psinfo32_t, pr_pid) BFD_HAVE_SYS_PROCFS_TYPE(lwpstatus_t) BFD_HAVE_SYS_PROCFS_TYPE(lwpxstatus_t) BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(lwpstatus_t, pr_context) diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index e5d010349c9..ca461b55dfe 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -2164,6 +2164,7 @@ scan_unit_for_symbols (struct comp_unit *unit) break; case DW_AT_abstract_origin: + case DW_AT_specification: func->name = find_abstract_instance_name (unit, &attr); break; diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 0c5b0cbd349..6cba217f5d4 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -229,11 +229,7 @@ struct elf_link_hash_entry }; /* Will references to this symbol always reference the symbol - in this object? STV_PROTECTED is excluded from the visibility test - here so that function pointer comparisons work properly. Since - function symbols not defined in an app are set to their .plt entry, - it's necessary for shared libs to also reference the .plt even - though the symbol is really local to the shared lib. */ + in this object? */ #define SYMBOL_REFERENCES_LOCAL(INFO, H) \ _bfd_elf_symbol_refs_local_p (H, INFO, 0) diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index bdca122e40f..30b5e02282e 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -4882,6 +4882,22 @@ _bfd_mn10300_elf_reloc_type_class (const Elf_Internal_Rela *rela) } } +/* Allocate space for an MN10300 extension to the bfd elf data structure. */ + +static bfd_boolean +mn10300_elf_mkobject (bfd *abfd) +{ + /* We do not actually need any extra room in the bfd elf data structure. + But we do need the object_id of the structure to be set to + MN10300_ELF_DATA so that elflink.c:elf_link_add_object_symols() will call + our mn10300_elf_check_relocs function which will then allocate space in + the .got section for any GOT based relocs. */ + return bfd_elf_allocate_object (abfd, sizeof (struct elf_obj_tdata), + MN10300_ELF_DATA); +} + +#define bfd_elf32_mkobject mn10300_elf_mkobject + #ifndef ELF_ARCH #define TARGET_LITTLE_SYM bfd_elf32_mn10300_vec #define TARGET_LITTLE_NAME "elf32-mn10300" diff --git a/bfd/elf.c b/bfd/elf.c index c0ffbd078b7..b57f88ca3b9 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -976,7 +976,9 @@ _bfd_elf_make_section_from_shdr (bfd *abfd, phdr = elf_tdata (abfd)->phdr; for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++) { - if (phdr->p_type == PT_LOAD + if (((phdr->p_type == PT_LOAD + && (hdr->sh_flags & SHF_TLS) == 0) + || phdr->p_type == PT_TLS) && ELF_SECTION_IN_SEGMENT (hdr, phdr)) { if ((flags & SEC_LOAD) == 0) @@ -3980,8 +3982,12 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) phdr_in_segment = FALSE; } - /* Create a final PT_LOAD program segment. */ - if (last_hdr != NULL) + /* Create a final PT_LOAD program segment, but not if it's just + for .tbss. */ + if (last_hdr != NULL + && (i - phdr_index != 1 + || ((last_hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) + != SEC_THREAD_LOCAL))) { m = make_mapping (abfd, sections, phdr_index, i, phdr_in_segment); if (m == NULL) @@ -4661,11 +4667,24 @@ assign_file_positions_for_load_sections (bfd *abfd, } else { - if (p->p_type == PT_LOAD) + if (p->p_type == PT_LOAD + || (this_hdr->sh_type == SHT_NOBITS + && (this_hdr->sh_flags & SHF_TLS) != 0 + && this_hdr->sh_offset == 0)) { - this_hdr->sh_offset = sec->filepos = off; - if (this_hdr->sh_type != SHT_NOBITS) - off += this_hdr->sh_size; + if (this_hdr->sh_type == SHT_NOBITS) + { + /* These sections don't really need sh_offset, + but give them one anyway. */ + bfd_vma adjust = vma_page_aligned_bias (this_hdr->sh_addr, + off, align); + this_hdr->sh_offset = sec->filepos = off + adjust; + } + else + { + this_hdr->sh_offset = sec->filepos = off; + off += this_hdr->sh_size; + } } if (this_hdr->sh_type != SHT_NOBITS) @@ -4731,7 +4750,8 @@ assign_file_positions_for_load_sections (bfd *abfd, sec = m->sections[i]; this_hdr = &(elf_section_data(sec)->this_hdr); - if (!ELF_SECTION_IN_SEGMENT_1 (this_hdr, p, check_vma, 0)) + if (!ELF_SECTION_IN_SEGMENT_1 (this_hdr, p, check_vma, 0) + && !ELF_TBSS_SPECIAL (this_hdr, p)) { (*_bfd_error_handler) (_("%B: section `%A' can't be allocated in segment %d"), @@ -4902,17 +4922,21 @@ assign_file_positions_for_non_load_sections (bfd *abfd, && (p->p_type != PT_NOTE || bfd_get_format (abfd) != bfd_core)) { - Elf_Internal_Shdr *hdr; - asection *sect; - BFD_ASSERT (!m->includes_filehdr && !m->includes_phdrs); - sect = m->sections[m->count - 1]; - hdr = &elf_section_data (sect)->this_hdr; - p->p_filesz = sect->filepos - m->sections[0]->filepos; - if (hdr->sh_type != SHT_NOBITS) - p->p_filesz += hdr->sh_size; + p->p_filesz = 0; p->p_offset = m->sections[0]->filepos; + for (i = m->count; i-- != 0;) + { + asection *sect = m->sections[i]; + Elf_Internal_Shdr *hdr = &elf_section_data (sect)->this_hdr; + if (hdr->sh_type != SHT_NOBITS) + { + p->p_filesz = (sect->filepos - m->sections[0]->filepos + + hdr->sh_size); + break; + } + } } } else if (m->includes_filehdr) @@ -7975,6 +7999,9 @@ elfcore_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) memcpy (&psinfo, note->descdata, sizeof (psinfo)); +#if defined (HAVE_PSINFO_T_PR_PID) || defined (HAVE_PRPSINFO_T_PR_PID) + elf_tdata (abfd)->core_pid = psinfo.pr_pid; +#endif elf_tdata (abfd)->core_program = _bfd_elfcore_strndup (abfd, psinfo.pr_fname, sizeof (psinfo.pr_fname)); @@ -7991,6 +8018,9 @@ elfcore_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) memcpy (&psinfo, note->descdata, sizeof (psinfo)); +#if defined (HAVE_PSINFO32_T_PR_PID) || defined (HAVE_PRPSINFO32_T_PR_PID) + elf_tdata (abfd)->core_pid = psinfo.pr_pid; +#endif elf_tdata (abfd)->core_program = _bfd_elfcore_strndup (abfd, psinfo.pr_fname, sizeof (psinfo.pr_fname)); diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index c7363753d49..42d9b46120b 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -1881,6 +1881,8 @@ ppc_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) return FALSE; case 128: /* Linux/PPC elf_prpsinfo. */ + elf_tdata (abfd)->core_pid + = bfd_get_32 (abfd, note->descdata + 16); elf_tdata (abfd)->core_program = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16); elf_tdata (abfd)->core_command diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c index 65f13b3caf3..99d22254bc6 100644 --- a/bfd/elf32-rx.c +++ b/bfd/elf32-rx.c @@ -20,6 +20,7 @@ #include "sysdep.h" #include "bfd.h" +#include "bfd_stdint.h" #include "libbfd.h" #include "elf-bfd.h" #include "elf/rx.h" diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 543a7272b28..1394ff544e4 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -2670,6 +2670,8 @@ ppc64_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) if (note->descsz != 136) return FALSE; + elf_tdata (abfd)->core_pid + = bfd_get_32 (abfd, note->descdata + 24); elf_tdata (abfd)->core_program = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16); elf_tdata (abfd)->core_command diff --git a/bfd/elflink.c b/bfd/elflink.c index 5a9d457d38e..891ce5d7df4 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -2881,8 +2881,10 @@ _bfd_elf_symbol_refs_local_p (struct elf_link_hash_entry *h, return TRUE; /* Function pointer equality tests may require that STV_PROTECTED - symbols be treated as dynamic symbols, even when we know that the - dynamic linker will resolve them locally. */ + symbols be treated as dynamic symbols. If the address of a + function not defined in an executable is set to that function's + plt entry in the executable, then the address of the function in + a shared library must also be the plt entry in the executable. */ return local_protected; } @@ -3814,7 +3816,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)) + notice_as_needed, 0, NULL)) goto error_free_vers; /* Clone the symbol table and sym hashes. Remember some @@ -4240,10 +4242,7 @@ error_free_dyn: We need to get the alignment from the section. */ align = new_sec->alignment_power; } - if (align > old_alignment - /* Permit an alignment power of zero if an alignment of one - is specified and no other alignments have been specified. */ - || (isym->st_value == 1 && old_alignment == 0)) + if (align > old_alignment) h->root.u.c.p->alignment_power = align; else h->root.u.c.p->alignment_power = old_alignment; @@ -4561,7 +4560,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)) + notice_not_needed, 0, NULL)) goto error_free_vers; free (old_tab); @@ -4575,7 +4574,7 @@ error_free_dyn: if (old_tab != NULL) { if (!(*info->callbacks->notice) (info, NULL, abfd, NULL, - notice_needed)) + notice_needed, 0, NULL)) goto error_free_vers; free (old_tab); old_tab = NULL; @@ -5724,11 +5723,12 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, { const char *verstr, *name; size_t namelen, verlen, newlen; - char *newname, *p; + char *newname, *p, leading_char; struct elf_link_hash_entry *newh; + leading_char = bfd_get_symbol_leading_char (output_bfd); name = d->pattern; - namelen = strlen (name); + namelen = strlen (name) + (leading_char != '\0'); verstr = t->name; verlen = strlen (verstr); newlen = namelen + verlen + 3; @@ -5736,7 +5736,8 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, newname = (char *) bfd_malloc (newlen); if (newname == NULL) return FALSE; - memcpy (newname, name, namelen); + newname[0] = leading_char; + memcpy (newname + (leading_char != '\0'), name, namelen); /* Check the hidden versioned definition. */ p = newname + namelen; @@ -6538,10 +6539,13 @@ bfd_elf_size_dynsym_hash_dynstr (bfd *output_bfd, struct bfd_link_info *info) } else { - unsigned long int maskwords, maskbitslog2; + unsigned long int maskwords, maskbitslog2, x; BFD_ASSERT (cinfo.min_dynindx != -1); - maskbitslog2 = bfd_log2 (cinfo.nsyms) + 1; + x = cinfo.nsyms; + maskbitslog2 = 1; + while ((x >>= 1) != 0) + ++maskbitslog2; if (maskbitslog2 < 3) maskbitslog2 = 5; else if ((1 << (maskbitslog2 - 2)) & cinfo.nsyms) diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index d42ad892121..26e591999e5 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -636,7 +636,7 @@ elfNN_ia64_relax_br (bfd_byte *contents, bfd_vma off) bfd_byte *hit_addr; hit_addr = (bfd_byte *) (contents + off); - br_slot = (long) hit_addr & 0x3; + br_slot = (intptr_t) hit_addr & 0x3; hit_addr -= br_slot; t0 = bfd_getl64 (hit_addr + 0); t1 = bfd_getl64 (hit_addr + 8); @@ -738,7 +738,7 @@ elfNN_ia64_relax_brl (bfd_byte *contents, bfd_vma off) bfd_vma t0, t1, i0, i1, i2; hit_addr = (bfd_byte *) (contents + off); - hit_addr -= (long) hit_addr & 0x3; + hit_addr -= (intptr_t) hit_addr & 0x3; t0 = bfd_getl64 (hit_addr); t1 = bfd_getl64 (hit_addr + 8); @@ -3874,7 +3874,7 @@ elfNN_ia64_install_value (bfd_byte *hit_addr, bfd_vma v, switch (opnd) { case IA64_OPND_IMMU64: - hit_addr -= (long) hit_addr & 0x3; + hit_addr -= (intptr_t) hit_addr & 0x3; t0 = bfd_getl64 (hit_addr); t1 = bfd_getl64 (hit_addr + 8); @@ -3903,7 +3903,7 @@ elfNN_ia64_install_value (bfd_byte *hit_addr, bfd_vma v, break; case IA64_OPND_TGT64: - hit_addr -= (long) hit_addr & 0x3; + hit_addr -= (intptr_t) hit_addr & 0x3; t0 = bfd_getl64 (hit_addr); t1 = bfd_getl64 (hit_addr + 8); @@ -3928,7 +3928,7 @@ elfNN_ia64_install_value (bfd_byte *hit_addr, bfd_vma v, break; default: - switch ((long) hit_addr & 0x3) + switch ((intptr_t) hit_addr & 0x3) { case 0: shift = 5; break; case 1: shift = 14; hit_addr += 3; break; diff --git a/bfd/hosts/x86-64linux.h b/bfd/hosts/x86-64linux.h index 27901c5fbfa..c32414068fa 100644 --- a/bfd/hosts/x86-64linux.h +++ b/bfd/hosts/x86-64linux.h @@ -40,6 +40,8 @@ typedef unsigned int uint32_t; #undef HAVE_PRPSINFO32_T #define HAVE_PRPSINFO32_T +#undef HAVE_PRPSINFO32_T_PR_PID +#define HAVE_PRPSINFO32_T_PR_PID #undef HAVE_PRSTATUS32_T #define HAVE_PRSTATUS32_T diff --git a/bfd/libbfd.c b/bfd/libbfd.c index 8b243784568..0c6755de780 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -431,9 +431,9 @@ DESCRIPTION .#define bfd_put_signed_8 \ . bfd_put_8 .#define bfd_get_8(abfd, ptr) \ -. (*(unsigned char *) (ptr) & 0xff) +. (*(const unsigned char *) (ptr) & 0xff) .#define bfd_get_signed_8(abfd, ptr) \ -. (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80) +. (((*(const unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80) . .#define bfd_put_16(abfd, val, ptr) \ . BFD_SEND (abfd, bfd_putx16, ((val),(ptr))) @@ -968,8 +968,12 @@ bfd_log2 (bfd_vma x) { unsigned int result = 0; - while ((x = (x >> 1)) != 0) + if (x <= 1) + return result; + --x; + do ++result; + while ((x >>= 1) != 0); return result; } diff --git a/bfd/linker.c b/bfd/linker.c index 1f02cbab545..283287a0fb5 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -1607,7 +1607,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, || (info->notice_hash != NULL && bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE) != NULL)) { - if (! (*info->callbacks->notice) (info, h, abfd, section, value)) + if (! (*info->callbacks->notice) (info, h, + abfd, section, value, flags, string)) return FALSE; } @@ -1640,7 +1641,6 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, /* Make a new weak undefined symbol. */ h->type = bfd_link_hash_undefweak; h->u.undef.abfd = abfd; - h->u.undef.weak = abfd; break; case CDEF: diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index a5b7f68b902..3583b91f449 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -2449,15 +2449,23 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) if (sec) { - bfd_size_type x = sec->rawsize ? sec->rawsize : sec->size; + bfd_size_type x = sec->rawsize; + bfd_byte *tmp_data = NULL; - if (x && bfd_get_section_contents (abfd, sec, pfinfo->contents, 0, x)) + if (x) + tmp_data = bfd_malloc (x); + + if (tmp_data != NULL) { - qsort (pfinfo->contents, - (size_t) ((sec->size size : x) / 12), - 12, sort_x64_pdata); - bfd_set_section_contents (pfinfo->output_bfd, sec, - pfinfo->contents, 0, x); + if (bfd_get_section_contents (abfd, sec, tmp_data, 0, x)) + { + qsort (tmp_data, + (size_t) (x / 12), + 12, sort_x64_pdata); + bfd_set_section_contents (pfinfo->output_bfd, sec, + tmp_data, 0, x); + } + free (tmp_data); } } } diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index 309c3a241be..322de62c2bd 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -1709,7 +1709,7 @@ _bfd_vms_slurp_etir (bfd *abfd, struct bfd_link_info *info) #if VMS_DEBUG _bfd_vms_debug (4, "etir: %s(%d)\n", _bfd_vms_etir_name (cmd), cmd); - _bfd_hexdump (8, ptr, cmd_length - 4, (long) ptr); + _bfd_hexdump (8, ptr, cmd_length - 4, (intptr_t) ptr); #endif switch (cmd) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 13ef346c882..0b3a1a00b41 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,21 @@ +2011-05-29 Alan Modra + + Apply from mainline + 2011-05-18 Nick Clifton + PR binutils/12753 + * nm.c (filter_symbols): Treat unique symbols as global symbols. + * doc/binutils.texi (nm): Mention that some lowercase letters + actually indicate global symbols. + + 2011-05-07 Alan Modra + * objcopy.c (copy_archive): Check bfd_openw result in unknown object + case. Rewrite without goto. + + 2011-04-03 H.J. Lu + PR binutils/12632 + * objcopy.c (copy_unknown_object): Make the archive element + readable. + 2011-03-01 Akos Pasztory PR binutils/12523 diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index d3285a5ead8..d8d1899caed 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -724,7 +724,9 @@ hexadecimal by default. @item The symbol type. At least the following types are used; others are, as well, depending on the object file format. If lowercase, the symbol is -local; if uppercase, the symbol is global (external). +usually local; if uppercase, the symbol is global (external). There +are however a few lowercase symbols that are shown for special global +symbols (@code{u}, @code{v} and @code{w}). @c Some more detail on exactly what these symbol types are used for @c would be nice. diff --git a/binutils/nm.c b/binutils/nm.c index 3b75edf3cd8..783087dd89b 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -436,6 +436,8 @@ filter_symbols (bfd *abfd, bfd_boolean is_dynamic, void *minisyms, else if (external_only) keep = ((sym->flags & BSF_GLOBAL) != 0 || (sym->flags & BSF_WEAK) != 0 + /* PR binutls/12753: Unique symbols are global too. */ + || (sym->flags & BSF_GNU_UNIQUE) != 0 || bfd_is_und_section (sym->section) || bfd_is_com_section (sym->section)); else diff --git a/binutils/objcopy.c b/binutils/objcopy.c index ac176df5896..54f070d8dad 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1,6 +1,6 @@ /* objcopy.c -- copy object file from input to output, optionally massaging it. Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -1399,7 +1399,9 @@ copy_unknown_object (bfd *ibfd, bfd *obfd) ncopied += tocopy; } - chmod (bfd_get_filename (obfd), buf.st_mode); + /* We should at least to be able to read it back when copying an + unknown object in an archive. */ + chmod (bfd_get_filename (obfd), buf.st_mode | S_IRUSR); free (cbuf); return TRUE; } @@ -2022,6 +2024,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, struct stat buf; int stat_status = 0; bfd_boolean del = TRUE; + bfd_boolean ok_object; /* Create an output file for this member. */ output_name = concat (dir, "/", @@ -2059,44 +2062,42 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, l->obfd = NULL; list = l; - if (bfd_check_format (this_element, bfd_object)) + ok_object = bfd_check_format (this_element, bfd_object); + if (!ok_object) + bfd_nonfatal_message (NULL, this_element, NULL, + _("Unable to recognise the format of file")); + + /* PR binutils/3110: Cope with archives + containing multiple target types. */ + if (force_output_target || !ok_object) + output_bfd = bfd_openw (output_name, output_target); + else + output_bfd = bfd_openw (output_name, bfd_get_target (this_element)); + + if (output_bfd == NULL) { - /* PR binutils/3110: Cope with archives - containing multiple target types. */ - if (force_output_target) - output_bfd = bfd_openw (output_name, output_target); - else - output_bfd = bfd_openw (output_name, bfd_get_target (this_element)); + bfd_nonfatal_message (output_name, NULL, NULL, NULL); + status = 1; + return; + } + + if (ok_object) + { + del = !copy_object (this_element, output_bfd, input_arch); - if (output_bfd == NULL) + if (del && bfd_get_arch (this_element) == bfd_arch_unknown) + /* Try again as an unknown object file. */ + ok_object = FALSE; + else if (!bfd_close (output_bfd)) { bfd_nonfatal_message (output_name, NULL, NULL, NULL); + /* Error in new object file. Don't change archive. */ status = 1; - return; } - - del = ! copy_object (this_element, output_bfd, input_arch); - - if (! del - || bfd_get_arch (this_element) != bfd_arch_unknown) - { - if (!bfd_close (output_bfd)) - { - bfd_nonfatal_message (output_name, NULL, NULL, NULL); - /* Error in new object file. Don't change archive. */ - status = 1; - } - } - else - goto copy_unknown_element; } - else - { - bfd_nonfatal_message (NULL, this_element, NULL, - _("Unable to recognise the format of file")); - output_bfd = bfd_openw (output_name, output_target); -copy_unknown_element: + if (!ok_object) + { del = !copy_unknown_object (this_element, output_bfd); if (!bfd_close_all_done (output_bfd)) { diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog index 678f82aef04..0b6a0a1ede9 100644 --- a/binutils/testsuite/ChangeLog +++ b/binutils/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2011-05-29 Alan Modra + + Apply from mainline + 2011-05-18 Nick Clifton + PR binutils/12753 + * lib/utils-lib.exp (run_dump_test): Allow nm as a program. + * binutils-all/nm.exp: Test running "nm -g" on an object file + containing a unique symbol. + 2011-02-10 Alan Modra Apply from mainline diff --git a/binutils/testsuite/binutils-all/nm.exp b/binutils/testsuite/binutils-all/nm.exp index 67d0cbdc087..685794d3235 100644 --- a/binutils/testsuite/binutils-all/nm.exp +++ b/binutils/testsuite/binutils-all/nm.exp @@ -98,6 +98,41 @@ if {![info exists vars(text_symbol)] \ pass "nm -g" } +if [is_elf_format] { + # PR binutils/12753 + # Test nm -g on a unique global symbol. + + # Only some targets support unique symbols. + if {([istarget "i?86-*-*"] + || [istarget "x86_64-*-*"] + || [istarget "arm-*-*"] + || [istarget "powerpc*-*-*"] + || [istarget "sparc*-*-*"])} then { + + if {![binutils_assemble $srcdir/$subdir/unique.s tmpdir/unique.o]} then { + fail "nm -g on unique symbols (assembling)" + } else { + if [is_remote host] { + set tmpfile [remote_download host tmpdir/unique.o] + } else { + set tmpfile tmpdir/unique.o + } + + set got [binutils_run $NM "$NMFLAGS -g $tmpfile"] + + if [regexp "u foo" $got] then { + pass "nm -g on unique symbols" + } else { + fail "nm -g on unique symbols" + } + + if { $verbose < 1 } { + remote_file host delete "tmpdir/unique.o" + } + } + } +} + # Test nm -P # This test does not work correctly on ECOFF targets, because ECOFF diff --git a/binutils/testsuite/lib/utils-lib.exp b/binutils/testsuite/lib/utils-lib.exp index 72e368cbb39..b96043b4d76 100644 --- a/binutils/testsuite/lib/utils-lib.exp +++ b/binutils/testsuite/lib/utils-lib.exp @@ -354,6 +354,7 @@ proc run_dump_test { name {extra_options {}} } { } strings { set program strings } elfedit { set program elfedit } + nm { set program nm } default { perror "unrecognized program option $opts(PROG) in $file.d" unresolved $testname diff --git a/gas/ChangeLog b/gas/ChangeLog index 827ea36bff5..596029fe786 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,28 @@ +2011-05-29 Alan Modra + + Apply from mainline + 2011-03-18 Alan Modra + * input-scrub.c (line_numberT): Delete. + (input_scrub_close): Reset line counters. + * messages.c (as_show_where): Don't print invalid line number. + (as_warn_internal, as_bad_internal): Likewise. + + 2011-03-18 Alan Modra + * read.c (read_a_source_file): Remove md_after_pass_hook. + Move "quit" label before set of dot_symbol. + * config/tc-d10v.h (md_after_pass_hook): Don't define. + * config/tc-d30v.h (md_after_pass_hook): Likewise. + * config/tc-m32r.h (md_after_pass_hook): Likewise. + (md_cleanup): Define to call m32r_fill_insn. + + 2011-03-10 Alan Modra + * gas/config/obj-elf.h (ELF_TARGET_SYMBOL_FIELDS, + TARGET_SYMBOL_FIELDS): Don't define. + * gas/config/tc-arc.c (arc_common): Use correct symbol "local" field. + + 2011-03-09 Michael Snyder + * dwarf2dbg.c (emit_fixed_inc_line_addr): Correct assert. + 2011-05-18 Andreas Krebbel Backported from mainline diff --git a/gas/config/obj-elf.h b/gas/config/obj-elf.h index ccfa8d294c9..0721654c043 100644 --- a/gas/config/obj-elf.h +++ b/gas/config/obj-elf.h @@ -1,6 +1,7 @@ /* ELF object file format. Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. + 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011 + Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -80,14 +81,6 @@ struct elf_obj_sy #define OBJ_SYMFIELD_TYPE struct elf_obj_sy -/* Symbol fields used by the ELF back end. */ -#define ELF_TARGET_SYMBOL_FIELDS unsigned int local:1; - -/* Don't change this; change ELF_TARGET_SYMBOL_FIELDS instead. */ -#ifndef TARGET_SYMBOL_FIELDS -#define TARGET_SYMBOL_FIELDS ELF_TARGET_SYMBOL_FIELDS -#endif - #ifndef FALSE #define FALSE 0 #define TRUE !FALSE diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c index b5d073efe78..8d2da96bc7b 100644 --- a/gas/config/tc-arc.c +++ b/gas/config/tc-arc.c @@ -1,6 +1,6 @@ /* tc-arc.c -- Assembler for the ARC Copyright 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2009 Free Software Foundation, Inc. + 2006, 2007, 2009, 2011 Free Software Foundation, Inc. Contributed by Doug Evans (dje@cygnus.com). This file is part of GAS, the GNU Assembler. @@ -934,7 +934,7 @@ arc_common (int localScope) S_SET_SIZE (symbolP, size); S_SET_SEGMENT (symbolP, bss_section); S_CLEAR_EXTERNAL (symbolP); - symbolP->local = 1; + symbol_get_obj (symbolP)->local = 1; subseg_set (old_sec, old_subsec); } else diff --git a/gas/config/tc-d10v.h b/gas/config/tc-d10v.h index 930f3a185dd..3c326248f31 100644 --- a/gas/config/tc-d10v.h +++ b/gas/config/tc-d10v.h @@ -1,6 +1,6 @@ /* tc-d10v.h -- Header file for tc-d10v.c. Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005, 2007, 2009, - 2010 Free Software Foundation, Inc. + 2010, 2011 Free Software Foundation, Inc. Written by Martin Hunt, Cygnus Support. This file is part of GAS, the GNU Assembler. @@ -47,7 +47,6 @@ long md_pcrel_from_section (struct fix *, segT); int d10v_cleanup (void); void d10v_frob_label (symbolS *); -#define md_after_pass_hook() d10v_cleanup () #define md_cleanup() d10v_cleanup () #define md_do_align(a,b,c,d,e) d10v_cleanup () #define tc_frob_label(sym) d10v_frob_label (sym) diff --git a/gas/config/tc-d30v.h b/gas/config/tc-d30v.h index 51935502d66..e75f3d81d0d 100644 --- a/gas/config/tc-d30v.h +++ b/gas/config/tc-d30v.h @@ -1,5 +1,5 @@ /* tc-310v.h -- Header file for tc-d30v.c. - Copyright 1997, 1998, 2000, 2001, 2002, 2005, 2007, 2009 + Copyright 1997, 1998, 2000, 2001, 2002, 2005, 2007, 2009, 2011 Free Software Foundation, Inc. Written by Martin Hunt, Cygnus Support. @@ -46,7 +46,6 @@ extern long md_pcrel_from_section (struct fix *, segT); #define md_number_to_chars number_to_chars_bigendian int d30v_cleanup (int); -#define md_after_pass_hook() d30v_cleanup (FALSE) #define md_cleanup() d30v_cleanup (FALSE) #define TC_START_LABEL(ch, s, ptr) (ch == ':' && d30v_cleanup (FALSE)) void d30v_start_line (void); diff --git a/gas/config/tc-m32r.h b/gas/config/tc-m32r.h index 9def7ba2c74..32657122758 100644 --- a/gas/config/tc-m32r.h +++ b/gas/config/tc-m32r.h @@ -1,6 +1,6 @@ /* tc-m32r.h -- Header file for tc-m32r.c. Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2007, 2009 Free Software Foundation, Inc. + 2007, 2009, 2011 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -101,10 +101,9 @@ extern int m32r_force_relocation (struct fix *); /* Ensure insns at labels are aligned to 32 bit boundaries. */ int m32r_fill_insn (int); -#define md_after_pass_hook() m32r_fill_insn (1) #define TC_START_LABEL(ch, s, ptr) (ch == ':' && m32r_fill_insn (0)) -#define md_cleanup m32r_elf_section_change_hook +#define md_cleanup() m32r_fill_insn (1) #define md_elf_section_change_hook m32r_elf_section_change_hook extern void m32r_elf_section_change_hook (void); diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c index 85c1f30e898..9910c17a810 100644 --- a/gas/dwarf2dbg.c +++ b/gas/dwarf2dbg.c @@ -1080,7 +1080,7 @@ emit_fixed_inc_line_addr (int line_delta, addressT addr_delta, fragS *frag, symbolS *to_sym; expressionS exp; - gas_assert (pexp->X_op = O_subtract); + gas_assert (pexp->X_op == O_subtract); to_sym = pexp->X_add_symbol; *p++ = DW_LNS_extended_op; diff --git a/gas/input-scrub.c b/gas/input-scrub.c index e1ff5cc0a50..d00b116d536 100644 --- a/gas/input-scrub.c +++ b/gas/input-scrub.c @@ -1,6 +1,6 @@ /* input_scrub.c - Break up input buffers into whole numbers of lines. Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 2000, 2001, 2003, 2005, 2006, 2007, 2008 + 2000, 2001, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -99,10 +99,9 @@ int macro_nest; static char *physical_input_file; static char *logical_input_file; -typedef unsigned int line_numberT; /* 1-origin line number in a source file. */ +/* 1-origin line number in a source file. */ /* A line ends in '\n' or eof. */ - -static line_numberT physical_input_line; +static unsigned int physical_input_line; static int logical_input_line; /* Struct used to save the state of the input handler during include files */ @@ -114,7 +113,7 @@ struct input_save { unsigned int buffer_length; char * physical_input_file; char * logical_input_file; - line_numberT physical_input_line; + unsigned int physical_input_line; int logical_input_line; int sb_index; sb from_sb; @@ -303,6 +302,8 @@ void input_scrub_close (void) { input_file_close (); + physical_input_line = 0; + logical_input_line = -1; } char * diff --git a/gas/messages.c b/gas/messages.c index 9ea1bce26dc..e1734f25063 100644 --- a/gas/messages.c +++ b/gas/messages.c @@ -1,6 +1,6 @@ /* messages.c - error reporter - Copyright 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001, - 2003, 2004, 2005, 2006, 2007, 2008 + 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -113,7 +113,12 @@ as_show_where (void) as_where (&file, &line); identify (file); if (file) - fprintf (stderr, "%s:%u: ", file, line); + { + if (line != 0) + fprintf (stderr, "%s:%u: ", file, line); + else + fprintf (stderr, "%s: ", file); + } } /* Send to stderr a string as a warning, and locate warning @@ -146,7 +151,12 @@ as_warn_internal (char *file, unsigned int line, char *buffer) identify (file); if (file) - fprintf (stderr, "%s:%u: ", file, line); + { + if (line != 0) + fprintf (stderr, "%s:%u: ", file, line); + else + fprintf (stderr, "%s: ", file); + } fprintf (stderr, _("Warning: ")); fputs (buffer, stderr); (void) putc ('\n', stderr); @@ -207,7 +217,12 @@ as_bad_internal (char *file, unsigned int line, char *buffer) identify (file); if (file) - fprintf (stderr, "%s:%u: ", file, line); + { + if (line != 0) + fprintf (stderr, "%s:%u: ", file, line); + else + fprintf (stderr, "%s: ", file); + } fprintf (stderr, _("Error: ")); fputs (buffer, stderr); (void) putc ('\n', stderr); diff --git a/gas/read.c b/gas/read.c index 7a5e512bb37..d224d1658e2 100644 --- a/gas/read.c +++ b/gas/read.c @@ -1124,14 +1124,10 @@ read_a_source_file (char *name) /* Report unknown char as error. */ demand_empty_rest_of_line (); } - -#ifdef md_after_pass_hook - md_after_pass_hook (); -#endif } - symbol_set_value_now (&dot_symbol); quit: + symbol_set_value_now (&dot_symbol); #ifdef md_cleanup md_cleanup (); diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index a467b632e95..356db301ab5 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2011-05-29 Alan Modra + + Apply from mainline + 2011-03-18 Alan Modra + * gas/i386/inval-equ-2.l: Adjust expected error. + * gas/symver/symver2.l: Likewise. + 2011-05-18 Andreas Krebbel Backported from mainline @@ -9,7 +16,7 @@ 2011-05-13 Matthew Gretton-Dann - Apply from mainline. + Apply from mainline. 2011-05-12 Matthew Gretton-Dann PR gas/12715 * gas/arm/neon-const.s: Add testcase for 64-bit Neon constants. diff --git a/gas/testsuite/gas/i386/inval-equ-2.l b/gas/testsuite/gas/i386/inval-equ-2.l index d598d0b80ee..aed89b4f5ee 100644 --- a/gas/testsuite/gas/i386/inval-equ-2.l +++ b/gas/testsuite/gas/i386/inval-equ-2.l @@ -1,7 +1,7 @@ .*: Assembler messages: -.*:8: Error: .* -.*:8: Error: .* -.*:8: Error: .* +.*: Error: .* +.*: Error: .* +.*: Error: .* GAS LISTING .* diff --git a/gas/testsuite/gas/symver/symver2.l b/gas/testsuite/gas/symver/symver2.l index 216b4870b6b..f9d73d76166 100644 --- a/gas/testsuite/gas/symver/symver2.l +++ b/gas/testsuite/gas/symver/symver2.l @@ -1,2 +1,2 @@ .*: Assembler messages: -.*:8: Error: invalid attempt to declare external version name as default in symbol `foo@@version1' +.*: Error: invalid attempt to declare external version name as default in symbol `foo@@version1' diff --git a/include/ChangeLog b/include/ChangeLog index 684e7b5d99f..1cf4f0b8abd 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,18 @@ +2011-05-29 Alan Modra + + Apply from mainline + 2011-05-17 Alan Modra + PR ld/12760 + * bfdlink.h (struct bfd_link_callbacks ): Add "flags" and + "string" param. + + 2011-05-16 Alan Modra + * bfdlink.h (struct bfd_link_hash_entry): Remove u.undef.weak field. + + 2011-04-25 Jan Kratochvil + * bfdlink.h (ENUM_BITFIELD): Remove. + * ansidecl.h (ENUM_BITFIELD): New, from gcc/system.h. + 2011-04-27 Alan Modra Backport from mainline. diff --git a/include/ansidecl.h b/include/ansidecl.h index 8b76647426b..c39ce2f5d70 100644 --- a/include/ansidecl.h +++ b/include/ansidecl.h @@ -416,6 +416,15 @@ So instead we use the macro below and test it against specific values. */ #define EXPORTED_CONST const #endif +/* Be conservative and only use enum bitfields with GCC. + FIXME: provide a complete autoconf test for buggy enum bitfields. */ + +#if (GCC_VERSION > 2000) +#define ENUM_BITFIELD(TYPE) __extension__ enum TYPE +#else +#define ENUM_BITFIELD(TYPE) unsigned int +#endif + #ifdef __cplusplus } #endif diff --git a/include/bfdlink.h b/include/bfdlink.h index 66f76455b19..22c29eae727 100644 --- a/include/bfdlink.h +++ b/include/bfdlink.h @@ -23,12 +23,6 @@ #ifndef BFDLINK_H #define BFDLINK_H -#if (__GNUC__ * 1000 + __GNUC_MINOR__ > 2000) -#define ENUM_BITFIELD(TYPE) __extension__ enum TYPE -#else -#define ENUM_BITFIELD(TYPE) unsigned int -#endif - /* Which symbols to strip during a link. */ enum bfd_link_strip { @@ -128,7 +122,6 @@ struct bfd_link_hash_entry undefined symbol list. */ struct bfd_link_hash_entry *next; bfd *abfd; /* BFD symbol was found in. */ - bfd *weak; /* BFD weak symbol was found in. */ } undef; /* bfd_link_hash_defined, bfd_link_hash_defweak. */ struct @@ -579,10 +572,13 @@ struct bfd_link_callbacks /* A function which is called when a symbol in notice_hash is defined or referenced. H is the symbol. ABFD, SECTION and ADDRESS are the (new) value of the symbol. If SECTION is - bfd_und_section, this is a reference. */ + bfd_und_section, this is a reference. FLAGS are the symbol + BSF_* flags. STRING is the name of the symbol to indirect to if + the sym is indirect, or the warning string if a warning sym. */ bfd_boolean (*notice) (struct bfd_link_info *, struct bfd_link_hash_entry *h, - bfd *abfd, asection *section, bfd_vma address); + bfd *abfd, asection *section, bfd_vma address, flagword flags, + const char *string); /* Error or warning link info message. */ void (*einfo) (const char *fmt, ...); diff --git a/ld/ChangeLog b/ld/ChangeLog index 13eaa9bb815..4484c3da2cc 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,54 @@ +2011-05-29 Alan Modra + + Apply from mainline + 2011-05-23 Alan Modra + PR 12763 + * ldlang.c (lang_output_section_find_by_flags): Match orphan .sdata2 + like sections to existing .sdata2, and similarly for orphan TLS + sections. + * emultempl/elf32.em (place_orphan): Exclude .tbss from orphan_bss. + + 2011-05-17 Alan Modra + PR ld/12760 + * ldmain.c (notice): Add "flags" and "string" param. + * plugin.c (plugin_notice): Likewise. Handle indirect, warning + and constructor syms. + + 2010-05-16 Daniel Jacobowitz + * ldlang.c (print_assignment): Use the symbol's section if we + use its value. + * ldexp.c (exp_fold_tree_1): Skip self-assignment. Expand + comment on copying symbol type. + + 2011-05-07 Dave Korn + PR ld/12365 + * scripttempl/pe.sc (__rt_psrelocs_start): New symbol definition. + (__rt_psrelocs_end): Likewise. + (__rt_psrelocs_size): Likewise difference between the above. + (__RUNTIME_PSEUDO_RELOC_LIST_END__): Move outside .rdata section + immediately after end of pseudo-reloc data. + (___RUNTIME_PSEUDO_RELOC_LIST_END___): Likewise. + (__RUNTIME_PSEUDO_RELOC_LIST__): Move outside .rdata section and + calculate backward from list end. + (___RUNTIME_PSEUDO_RELOC_LIST___): Likewise. + * scripttempl/pep.sc: Likewise. + + 2011-03-29 Alan Modra + PR ld/12613 + * ldlex.l (lex_warn_invalid): Don't assume char is unsigned. + + 2011-03-10 Dave Korn + * emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Preserve + alignment of input sections when creating orphan output sections + during relocatable link. + * emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise. + + 2011-02-14 Mike Frysinger + * ldlang.c (lang_vers_match): Declare a new c_sym, assign it to + the bfd_demangle of sym, change users of sym to c_sym when not + already demangling, and free when done. Change callers of + cplus_demangle to bfd_demangle. + 2011-05-16 H.J. Lu PR ld/12760 diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index ddcd5901fd6..62a86ca2178 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1919,7 +1919,7 @@ gld${EMULATION_NAME}_place_orphan (asection *s, && ((iself && sh_type == SHT_NOTE) || (!iself && CONST_STRNEQ (secname, ".note")))) place = &hold[orphan_interp]; - else if ((s->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0) + else if ((s->flags & (SEC_LOAD | SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) == 0) place = &hold[orphan_bss]; else if ((s->flags & SEC_SMALL_DATA) != 0) place = &hold[orphan_sdata]; diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index f9085f2fe76..cad49d28a5b 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -2009,10 +2009,17 @@ gld_${EMULATION_NAME}_place_orphan (asection *s, ->output_section_statement); } - /* All sections in an executable must be aligned to a page boundary. */ + /* All sections in an executable must be aligned to a page boundary. + In a relocatable link, just preserve the incoming alignment; the + address is discarded by lang_insert_orphan in that case, anyway. */ address = exp_unop (ALIGN_K, exp_nameop (NAME, "__section_alignment__")); os = lang_insert_orphan (s, secname, constraint, after, place, address, &add_child); + if (link_info.relocatable) + { + os->section_alignment = s->alignment_power; + os->bfd_section->alignment_power = s->alignment_power; + } } /* If the section name has a '\$', sort it with the other '\$' diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index 90793ea9b63..78751bb71b3 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -1745,10 +1745,17 @@ gld_${EMULATION_NAME}_place_orphan (asection *s, ->output_section_statement); } - /* All sections in an executable must be aligned to a page boundary. */ + /* All sections in an executable must be aligned to a page boundary. + In a relocatable link, just preserve the incoming alignment; the + address is discarded by lang_insert_orphan in that case, anyway. */ address = exp_unop (ALIGN_K, exp_nameop (NAME, "__section_alignment__")); os = lang_insert_orphan (s, secname, constraint, after, place, address, &add_child); + if (link_info.relocatable) + { + os->section_alignment = s->alignment_power; + os->bfd_section->alignment_power = s->alignment_power; + } } /* If the section name has a '\$', sort it with the other '\$' diff --git a/ld/ldexp.c b/ld/ldexp.c index f70634c5c61..68617d8553f 100644 --- a/ld/ldexp.c +++ b/ld/ldexp.c @@ -832,6 +832,8 @@ exp_fold_tree_1 (etree_type *tree) } else { + etree_type *name; + struct bfd_link_hash_entry *h = NULL; if (tree->type.node_class == etree_provide) @@ -849,6 +851,23 @@ exp_fold_tree_1 (etree_type *tree) } } + name = tree->assign.src; + if (name->type.node_class == etree_trinary) + { + exp_fold_tree_1 (name->trinary.cond); + if (expld.result.valid_p) + name = (expld.result.value + ? name->trinary.lhs : name->trinary.rhs); + } + + if (name->type.node_class == etree_name + && name->type.node_code == NAME + && strcmp (tree->assign.dst, name->name.name) == 0) + /* Leave it alone. Do not replace a symbol with its own + output address, in case there is another section sizing + pass. Folding does not preserve input sections. */ + break; + exp_fold_tree_1 (tree->assign.src); if (expld.result.valid_p || (expld.phase == lang_first_phase_enum @@ -876,7 +895,8 @@ exp_fold_tree_1 (etree_type *tree) tree->type.node_class = etree_provided; /* Copy the symbol type if this is a simple assignment of - one symbol to annother. */ + one symbol to another. This could be more general + (e.g. a ?: operator with NAMEs in each branch). */ if (tree->assign.src->type.node_class == etree_name) { struct bfd_link_hash_entry *hsrc; diff --git a/ld/ldlang.c b/ld/ldlang.c index cba509b84e5..8b05d8e1203 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1526,8 +1526,14 @@ lang_output_section_find_by_flags (const asection *sec, } flags ^= sec->flags; if (!(flags & (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD - | SEC_READONLY)) - && !(look->flags & (SEC_SMALL_DATA | SEC_THREAD_LOCAL))) + | SEC_READONLY | SEC_SMALL_DATA)) + || (!(flags & (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD + | SEC_READONLY)) + && !(look->flags & SEC_SMALL_DATA)) + || (!(flags & (SEC_THREAD_LOCAL | SEC_ALLOC)) + && (look->flags & SEC_THREAD_LOCAL) + && (!(flags & SEC_LOAD) + || (look->flags & SEC_LOAD)))) found = look; } } @@ -3995,9 +4001,8 @@ print_assignment (lang_assignment_statement_type *assignment, if (h) { value = h->u.def.value; - - if (expld.result.section != NULL) - value += expld.result.section->vma; + value += h->u.def.section->output_section->vma; + value += h->u.def.section->output_offset; minfo ("[0x%V]", value); } @@ -7387,19 +7392,29 @@ lang_vers_match (struct bfd_elf_version_expr_head *head, struct bfd_elf_version_expr *prev, const char *sym) { + const char *c_sym; const char *cxx_sym = sym; const char *java_sym = sym; struct bfd_elf_version_expr *expr = NULL; + enum demangling_styles curr_style; + + curr_style = CURRENT_DEMANGLING_STYLE; + cplus_demangle_set_style (no_demangling); + c_sym = bfd_demangle (link_info.output_bfd, sym, DMGL_NO_OPTS); + if (!c_sym) + c_sym = sym; + cplus_demangle_set_style (curr_style); if (head->mask & BFD_ELF_VERSION_CXX_TYPE) { - cxx_sym = cplus_demangle (sym, DMGL_PARAMS | DMGL_ANSI); + cxx_sym = bfd_demangle (link_info.output_bfd, sym, + DMGL_PARAMS | DMGL_ANSI); if (!cxx_sym) cxx_sym = sym; } if (head->mask & BFD_ELF_VERSION_JAVA_TYPE) { - java_sym = cplus_demangle (sym, DMGL_JAVA); + java_sym = bfd_demangle (link_info.output_bfd, sym, DMGL_JAVA); if (!java_sym) java_sym = sym; } @@ -7413,10 +7428,10 @@ lang_vers_match (struct bfd_elf_version_expr_head *head, case 0: if (head->mask & BFD_ELF_VERSION_C_TYPE) { - e.pattern = sym; + e.pattern = c_sym; expr = (struct bfd_elf_version_expr *) htab_find ((htab_t) head->htab, &e); - while (expr && strcmp (expr->pattern, sym) == 0) + while (expr && strcmp (expr->pattern, c_sym) == 0) if (expr->mask == BFD_ELF_VERSION_C_TYPE) goto out_ret; else @@ -7474,12 +7489,14 @@ lang_vers_match (struct bfd_elf_version_expr_head *head, else if (expr->mask == BFD_ELF_VERSION_CXX_TYPE) s = cxx_sym; else - s = sym; + s = c_sym; if (fnmatch (expr->pattern, s, 0) == 0) break; } out_ret: + if (c_sym != sym) + free ((char *) c_sym); if (cxx_sym != sym) free ((char *) cxx_sym); if (java_sym != sym) diff --git a/ld/ldlex.l b/ld/ldlex.l index 3213cf7c050..451d0ac8f23 100644 --- a/ld/ldlex.l +++ b/ld/ldlex.l @@ -688,7 +688,7 @@ lex_warn_invalid (char *where, char *what) if (! ISPRINT (*what)) { - sprintf (buf, "\\%03o", (unsigned int) *what); + sprintf (buf, "\\%03o", *(unsigned char *) what); what = buf; } diff --git a/ld/ldmain.c b/ld/ldmain.c index bfa6066b097..96f3bdaf3eb 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -151,7 +151,7 @@ static bfd_boolean unattached_reloc (struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma); static bfd_boolean notice (struct bfd_link_info *, struct bfd_link_hash_entry *, - bfd *, asection *, bfd_vma); + bfd *, asection *, bfd_vma, flagword, const char *); static struct bfd_link_callbacks link_callbacks = { @@ -1483,7 +1483,9 @@ notice (struct bfd_link_info *info, struct bfd_link_hash_entry *h, bfd *abfd, asection *section, - bfd_vma value) + bfd_vma value, + flagword flags ATTRIBUTE_UNUSED, + const char *string ATTRIBUTE_UNUSED) { const char *name; diff --git a/ld/plugin.c b/ld/plugin.c index ca7b0b85509..acd47f3f012 100644 --- a/ld/plugin.c +++ b/ld/plugin.c @@ -125,9 +125,9 @@ static const enum ld_plugin_tag tv_header_tags[] = static const size_t tv_header_size = ARRAY_SIZE (tv_header_tags); /* Forward references. */ -static bfd_boolean plugin_notice (struct bfd_link_info *info, - struct bfd_link_hash_entry *h, bfd *abfd, - asection *section, bfd_vma value); +static bfd_boolean plugin_notice (struct bfd_link_info *, + struct bfd_link_hash_entry *, bfd *, + asection *, bfd_vma, flagword, const char *); #if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) @@ -908,7 +908,9 @@ plugin_notice (struct bfd_link_info *info, struct bfd_link_hash_entry *h, bfd *abfd, asection *section, - bfd_vma value) + bfd_vma value, + flagword flags, + const char *string) { if (h != NULL) { @@ -918,8 +920,33 @@ plugin_notice (struct bfd_link_info *info, if (is_ir_dummy_bfd (abfd)) return TRUE; + /* Making an indirect symbol counts as a reference unless this + is a brand new symbol. */ + if (bfd_is_ind_section (section) + || (flags & BSF_INDIRECT) != 0) + { + if (h->type != bfd_link_hash_new) + { + struct bfd_link_hash_entry *inh; + + h->non_ir_ref = TRUE; + inh = bfd_wrapped_link_hash_lookup (abfd, info, string, FALSE, + FALSE, FALSE); + if (inh != NULL) + inh->non_ir_ref = TRUE; + } + } + + /* Nothing to do here for warning symbols. */ + else if ((flags & BSF_WARNING) != 0) + ; + + /* Nothing to do here for constructor symbols. */ + else if ((flags & BSF_CONSTRUCTOR) != 0) + ; + /* If this is a ref, set non_ir_ref. */ - if (bfd_is_und_section (section)) + else if (bfd_is_und_section (section)) h->non_ir_ref = TRUE; /* Otherwise, it must be a new def. Ensure any symbol defined @@ -945,6 +972,7 @@ plugin_notice (struct bfd_link_info *info, || (info->notice_hash != NULL && bfd_hash_lookup (info->notice_hash, h->root.string, FALSE, FALSE) != NULL)) - return (*orig_callbacks->notice) (info, h, abfd, section, value); + return (*orig_callbacks->notice) (info, h, + abfd, section, value, flags, string); return TRUE; } diff --git a/ld/scripttempl/pe.sc b/ld/scripttempl/pe.sc index 7d52cc542cf..2f8b09129f3 100644 --- a/ld/scripttempl/pe.sc +++ b/ld/scripttempl/pe.sc @@ -106,12 +106,15 @@ SECTIONS .rdata ${RELOCATING+BLOCK(__section_alignment__)} : { ${R_RDATA} - ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;} - ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = .;} + ${RELOCATING+__rt_psrelocs_start = .;} *(.rdata_runtime_pseudo_reloc) - ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} - ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} + ${RELOCATING+__rt_psrelocs_end = .;} } + ${RELOCATING+__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;} + ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} + ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} + ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;} + ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;} .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} : { diff --git a/ld/scripttempl/pep.sc b/ld/scripttempl/pep.sc index 8fa5f052d6b..decbd666fec 100644 --- a/ld/scripttempl/pep.sc +++ b/ld/scripttempl/pep.sc @@ -107,12 +107,15 @@ SECTIONS .rdata ${RELOCATING+BLOCK(__section_alignment__)} : { ${R_RDATA} - ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;} - ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = .;} + ${RELOCATING+__rt_psrelocs_start = .;} *(.rdata_runtime_pseudo_reloc) - ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} - ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} + ${RELOCATING+__rt_psrelocs_end = .;} } + ${RELOCATING+__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;} + ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} + ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} + ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;} + ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;} .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} : { diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 4dfdd578558..1a994bc7403 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,19 @@ +2011-05-24 Hans-Peter Nilsson + + * ld-cris/tls-e-tpoffcomm1.d: Adjust for second PR12763 change, + setting TLS file offset. + +2011-05-21 Hans-Peter Nilsson + + * ld-cris/tls-e-tpoffcomm1.d: Adjust for PR12763 change removing + empty program header. + +2011-05-07 Dave Korn + + PR ld/12365 + * ld-plugin/plugin-7.d: Allow underscore in error message. + * ld-plugin/plugin-8.d: Likewise. + 2012-05-25 H.J. Lu Backport from mainline diff --git a/ld/testsuite/ld-cris/tls-e-tpoffcomm1.d b/ld/testsuite/ld-cris/tls-e-tpoffcomm1.d index 69780cfd573..23d52ee06da 100644 --- a/ld/testsuite/ld-cris/tls-e-tpoffcomm1.d +++ b/ld/testsuite/ld-cris/tls-e-tpoffcomm1.d @@ -11,35 +11,33 @@ Program Header: LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13 - filesz 0x0+a4 memsz 0x0+a4 flags r-x - LOAD off 0x0+a4 vaddr 0x0+820a4 paddr 0x0+820a4 align 2\*\*13 - filesz 0x0+ memsz 0x0+ flags rw- - TLS off 0x0+a4 vaddr 0x0+820a4 paddr 0x0+820a4 align 2\*\*2 + filesz 0x0+84 memsz 0x0+84 flags r-x + TLS off 0x0+84 vaddr 0x0+82084 paddr 0x0+82084 align 2\*\*2 filesz 0x0+ memsz 0x0+8 flags r-- private flags = 0: Sections: Idx Name Size VMA LMA File off Algn - 0 .text 0+10 0+80094 0+80094 0+94 2\*\*1 + 0 .text 0+10 0+80074 0+80074 0+74 2\*\*1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .tbss 0+8 0+820a4 0+820a4 0+a4 2\*\*2 + 1 .tbss 0+8 0+82084 0+82084 0+84 2\*\*2 ALLOC, THREAD_LOCAL SYMBOL TABLE: -0+80094 l d .text 0+ .text -0+820a4 l d .tbss 0+ .tbss -0+80098 l F .text 0+c do_test -0+80094 g .text 0+ _start -0+820a4 g \*ABS\* 0+ __bss_start +0+80074 l d .text 0+ .text +0+82084 l d .tbss 0+ .tbss +0+80078 l F .text 0+c do_test +0+80074 g .text 0+ _start +0+82084 g \*ABS\* 0+ __bss_start 0+ g .tbss 0+4 foo -0+820a4 g \*ABS\* 0+ _edata -0+820c0 g \*ABS\* 0+ _end +0+82084 g \*ABS\* 0+ _edata +0+820a0 g \*ABS\* 0+ _end 0+4 g .tbss 0+4 bar #... Disassembly of section .text: -00080094 <_start>: - 80094: 41b2 moveq 1,\$r11 +00080074 <_start>: + 80074: 41b2 moveq 1,\$r11 #... -00080098 : - 80098: 2f0e f8ff ffff add.d 0xfffffff8,\$r0 - 8009e: 2f1e fcff ffff add.d 0xfffffffc,\$r1 +00080078 : + 80078: 2f0e f8ff ffff add.d 0xfffffff8,\$r0 + 8007e: 2f1e fcff ffff add.d 0xfffffffc,\$r1 diff --git a/ld/testsuite/ld-plugin/plugin-7.d b/ld/testsuite/ld-plugin/plugin-7.d index 04f41392ca6..4d0b9d7d91f 100644 --- a/ld/testsuite/ld-plugin/plugin-7.d +++ b/ld/testsuite/ld-plugin/plugin-7.d @@ -26,6 +26,6 @@ hook called: claim_file tmpdir/func.o \[@0/.* CLAIMED hook called: claim_file tmpdir/text.o \[@0/.* not claimed #... hook called: all symbols read. -`func' referenced in section `\.text.*' of tmpdir/main.o: defined in discarded section .* +`_?func' referenced in section `\.text.*' of tmpdir/main.o: defined in discarded section .* hook called: cleanup. #... diff --git a/ld/testsuite/ld-plugin/plugin-8.d b/ld/testsuite/ld-plugin/plugin-8.d index 003537c94f4..a589f01efc6 100644 --- a/ld/testsuite/ld-plugin/plugin-8.d +++ b/ld/testsuite/ld-plugin/plugin-8.d @@ -30,6 +30,6 @@ hook called: claim_file tmpdir/text.o \[@0/.* not claimed hook called: all symbols read. Sym: '_?func' Resolution: LDPR_PREVAILING_DEF Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY -`func' referenced in section `\.text.*' of tmpdir/main.o: defined in discarded section .* +`_?func' referenced in section `\.text.*' of tmpdir/main.o: defined in discarded section .* hook called: cleanup. #...