+2011-10-19 Alan Modra <amodra@gmail.com>
+
+ PR ld/13177
+ * elflink.c (_bfd_elf_gc_mark_rsec): Set symbol "mark".
+ (elf_gc_sweep_symbol): Don't test plt/got refcounts, instead test
+ "mark". Hide undefweak too. Clear def_regular and ref_regular.
+ * elf-m10300.c (mn10300_elf_relocate_section): Ignore unresolved
+ reloc errors from garbage-collected code.
+ * elf32-arm.c (elf32_arm_relocate_section): Likewise.
+ * elf32-bfin.c (bfin_relocate_section): Likewise.
+ (bfinfdpic_relocate_section): Likewise.
+ * elf32-cris.c (cris_elf_relocate_section): Likewise.
+ * elf32-frv.c (elf32_frv_relocate_section): Likewise.
+ * elf32-i386.c (elf_i386_relocate_section): Likewise.
+ * elf32-m32r.c (m32r_elf_relocate_section): Likewise.
+ * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+ * elf32-ppc.c (ppc_elf_relocate_section): Likewise.
+ * elf32-s390.c (elf_s390_relocate_section): Likewise.
+ * elf32-sh.c (sh_elf_relocate_section): Likewise.
+ * elf32-spu.c (spu_elf_relocate_section): Likewise.
+ * elf32-tilepro.c (tilepro_elf_relocate_section): Likewise.
+ * elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
+ * elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
+ * elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
+ * elf64-s390.c (elf_s390_relocate_section): Likewise.
+ * elf64-sh64.c (sh_elf64_relocate_section): Likewise.
+ * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+ * elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.
+ * elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise.
+
2011-10-19 Alan Modra <amodra@gmail.com>
PR ld/13311
obscure cases sec->output_section will be NULL. */
relocation = 0;
- else if (!info->relocatable && unresolved_reloc)
+ else if (!info->relocatable && unresolved_reloc
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
+
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
input_bfd,
not process them. */
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
- && h->def_dynamic))
+ && h->def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
{
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
because such sections are not SEC_ALLOC and thus ld.so will
not process them. */
if (unresolved_reloc
- && !((input_section->flags & SEC_DEBUGGING) != 0 && h->def_dynamic))
+ && !((input_section->flags & SEC_DEBUGGING) != 0 && h->def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
{
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable relocation against symbol `%s'"),
default:
non_fdpic:
picrel = NULL;
- if (h && ! BFINFDPIC_SYM_LOCAL (info, h))
+ if (h && ! BFINFDPIC_SYM_LOCAL (info, h)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
{
info->callbacks->warning
(info, _("relocation references symbol not defined in the module"),
|| r_type == R_CRIS_16_PCREL
|| r_type == R_CRIS_32_PCREL))
relocation = 0;
- else if (!info->relocatable && unresolved_reloc)
+ else if (!info->relocatable && unresolved_reloc
+ && (_bfd_elf_section_offset (output_bfd, info,
+ input_section,
+ rel->r_offset)
+ != (bfd_vma) -1))
{
_bfd_error_handler
(_("%B, section %A: unresolvable relocation %s against symbol `%s'"),
default:
non_fdpic:
picrel = NULL;
- if (h && ! FRVFDPIC_SYM_LOCAL (info, h))
+ if (h
+ && ! FRVFDPIC_SYM_LOCAL (info, h)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
{
info->callbacks->einfo
(_("%H: relocation references symbol"
not process them. */
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
- && h->def_dynamic))
+ && h->def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
{
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
relocation = (h->root.u.def.value
+ sec->output_section->vma
+ sec->output_offset);
- else if (!info->relocatable)
+ else if (!info->relocatable
+ && (_bfd_elf_section_offset (output_bfd, info,
+ input_section,
+ rel->r_offset)
+ != (bfd_vma) -1))
{
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
not process them. */
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
- && h->def_dynamic))
+ && h->def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
{
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
- && h->def_dynamic))
+ && h->def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
{
info->callbacks->einfo
(_("%P: %H: unresolvable %s relocation against symbol `%s'\n"),
not process them. */
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
- && h->def_dynamic))
+ && h->def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
input_bfd,
STT_DATALABEL on the way to it. */
| ((h->other & STO_SH5_ISA32) != 0
&& ! seen_stt_datalabel));
- else if (!info->relocatable)
+ else if (!info->relocatable
+ && (_bfd_elf_section_offset (output_bfd, info,
+ input_section,
+ rel->r_offset)
+ != (bfd_vma) -1))
{
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
else if (is_ea_sym)
unresolved_reloc = TRUE;
- if (unresolved_reloc)
+ if (unresolved_reloc
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
{
(*_bfd_error_handler)
(_("%B(%s+0x%lx): unresolvable %s relocation against symbol `%s'"),
not process them. */
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
- && h->def_dynamic))
+ && h->def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
input_bfd,
not process them. */
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
- && h->def_dynamic))
+ && h->def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
{
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
bfd_vma value;
bfd_vma addend;
bfd_boolean dynamic_symbol_p;
+ bfd_boolean unresolved_reloc = FALSE;
bfd_boolean undef_weak_ref = FALSE;
unsigned long r_type;
else
{
bfd_boolean warned;
- bfd_boolean unresolved_reloc;
struct elf_link_hash_entry *hh;
struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
else if (info->shared
&& r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC)
- && !undef_weak_ref)
+ && !undef_weak_ref
+ && !(unresolved_reloc
+ && (_bfd_elf_section_offset (output_bfd, info,
+ input_section,
+ rel->r_offset)
+ == (bfd_vma) -1)))
{
if (r_type == R_ALPHA_REFLONG)
{
/* ??? .eh_frame references to discarded sections will be smashed
to relocations against SHN_UNDEF. The .eh_frame format allows
NULL to be encoded as 0 in any format, so this works here. */
- if (r_symndx == STN_UNDEF)
+ if (r_symndx == STN_UNDEF
+ || (unresolved_reloc
+ && _bfd_elf_section_offset (output_bfd, info,
+ input_section,
+ rel->r_offset) == (bfd_vma) -1))
howto = (elf64_alpha_howto_table
+ (r_type - R_ALPHA_SREL32 + R_ALPHA_REFLONG));
goto default_reloc;
not process them. */
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
- && h->elf.def_dynamic))
+ && h->elf.def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
{
info->callbacks->einfo
(_("%P: %H: unresolvable %s relocation against symbol `%s'\n"),
not process them. */
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
- && h->def_dynamic))
+ && h->def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
input_bfd,
STT_DATALABEL on the way to it. */
| ((h->other & STO_SH5_ISA32) != 0
&& ! seen_stt_datalabel));
- else if (!info->relocatable)
+ else if (!info->relocatable
+ && (_bfd_elf_section_offset (output_bfd, info,
+ input_section,
+ rel->r_offset)
+ != (bfd_vma) -1))
{
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
not process them. */
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
- && h->def_dynamic))
+ && h->def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
input_bfd,
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ h->mark = 1;
return (*gc_mark_hook) (sec, info, cookie->rel, h, NULL);
}
static bfd_boolean
elf_gc_sweep_symbol (struct elf_link_hash_entry *h, void *data)
{
- if (((h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- && !h->root.u.def.section->gc_mark
- && (!(h->root.u.def.section->owner->flags & DYNAMIC)
- || (h->plt.refcount <= 0
- && h->got.refcount <= 0)))
- || (h->root.type == bfd_link_hash_undefined
- && h->plt.refcount <= 0
- && h->got.refcount <= 0))
- {
- struct elf_gc_sweep_symbol_info *inf =
- (struct elf_gc_sweep_symbol_info *) data;
+ if (!h->mark
+ && (((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && !h->root.u.def.section->gc_mark)
+ || h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak))
+ {
+ struct elf_gc_sweep_symbol_info *inf;
+
+ inf = (struct elf_gc_sweep_symbol_info *) data;
(*inf->hide_symbol) (inf->info, h, TRUE);
+ h->def_regular = 0;
+ h->ref_regular = 0;
+ h->ref_regular_nonweak = 0;
}
return TRUE;
not process them. */
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
- && h->def_dynamic))
+ && h->def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
input_bfd,
not process them. */
if (unresolved_reloc
&& !((input_section->flags & SEC_DEBUGGING) != 0
- && h->def_dynamic))
+ && h->def_dynamic)
+ && _bfd_elf_section_offset (output_bfd, info, input_section,
+ rel->r_offset) != (bfd_vma) -1)
(*_bfd_error_handler)
(_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
input_bfd,
+2011-10-19 Alan Modra <amodra@gmail.com>
+
+ * ld-elf/elf.exp: Move test for shared lib support..
+ * lib/ld-lib.exp (check_shared_lib_support): ..to here. Add m68hc1*,
+ and s/ms1/mt/.
+ (check_gc_sections_available): Match hppa*64 not hppa64. Comment.
+ * ld-gc/libpersonality.s: New.
+ * ld-gc/personality.s, * ld-gc/personality.d: New.
+ * ld-gc/gc.exp: Run personality test.
+
2011-10-18 David S. Miller <davem@davemloft.net>
* ld-sparc/tlssunbin32.dd: Update for TLS call relaxation fix
# should not seg-fault whilst creating the binary.
#
# Only run the test on targets thats support creating shared libraries.
-if { ! [istarget arc-*-*]
- && ! [istarget avr-*-*]
- && ! [istarget cr16-*-*]
- && ! [istarget cris*-*-*]
- && ! [istarget crx-*-*]
- && ! [istarget d10v-*-*]
- && ! [istarget d30v-*-*]
- && ! [istarget dlx-*-*]
- && ! [istarget fr30-*-*]
- && ! [istarget frv-*-*]
- && ! [istarget h8300-*-*]
- && ! [istarget i860-*-*]
- && ! [istarget i960-*-*]
- && ! [istarget ip2k-*-*]
- && ! [istarget iq2000-*-*]
- && ! [istarget lm32-*-*]
- && ! [istarget m32c-*-*]
- && ! [istarget m32r-*-*]
- && ! [istarget mcore*-*-*]
- && ! [istarget mep-*-*]
- && ! [istarget microblaze-*-*]
- && ! [istarget mn10200-*-*]
- && ! [istarget moxie-*-*]
- && ! [istarget ms1-*-*]
- && ! [istarget msp430-*-*]
- && ! [istarget openrisc-*-*]
- && ! [istarget or32-*-*]
- && ! [istarget pj-*-*]
- && ! [istarget rx-*-*]
- && ! [istarget spu-*-*]
- && ! [istarget v850*-*-*]
- && ! [istarget xstormy16-*-*]
- && ! [istarget *-*-irix*]
- && ! [istarget *-*-rtems] } {
+if { [check_shared_lib_support] } then {
run_ld_link_tests {
{"Build shared library for next test"
"-shared" "" "note-3.s" {} "note-3.so" }
run_dump_test "noent"
run_dump_test "abi-note"
run_dump_test "start"
+
+if { [is_elf_format] && [check_shared_lib_support] } then {
+ set gasopt ""
+ if { [istarget tic6x-*] } then {
+ set gasopt "-mpic -mpid=near"
+ }
+ if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/libpersonality.s tmpdir/libpersonality.o]
+ || ![ld_simple_link $ld tmpdir/libpersonality.so "-shared tmpdir/libpersonality.o"] } then {
+ fail libpersonality
+ } else {
+ run_dump_test "personality"
+ }
+}
+
if { [is_remote host] || [which $CC] != 0 } {
if { [istarget "*-*-linux*"]
|| [istarget "*-*-gnu*"] } {
--- /dev/null
+ .weak __gxx_personality_v0
+ .type __gxx_personality_v0,%function
+__gxx_personality_v0:
+ .long 0
+ .size __gxx_personality_v0, . - __gxx_personality_v0
+
+ .globl __gxx_personality_v1
+ .type __gxx_personality_v1,%function
+__gxx_personality_v1:
+ .long 0
+ .size __gxx_personality_v1, . - __gxx_personality_v1
--- /dev/null
+#name: --gc-sections with __gxx_personality
+#ld: --gc-sections -e main -L tmpdir -lpersonality
+#nm: -n
+#xfail: bfin-*-* cris*-*-* frv-*-* mn10300-*-* vax-*-* xtensa-*-*
+# above targets don't support cfi
+
+#failif
+#...
+.*gxx_personality.*
+#...
--- /dev/null
+ .section .text.loseme,"ax",%progbits
+ .globl loseme
+ .type loseme,%function
+loseme:
+ .cfi_startproc
+ .cfi_personality 0,__gxx_personality_v0
+ .long 0
+ .cfi_endproc
+ .size loseme, . - loseme
+
+ .section .text.loseme2,"ax",%progbits
+ .globl loseme2
+ .type loseme2,%function
+loseme2:
+ .cfi_startproc
+ .cfi_personality 0,__gxx_personality_v1
+ .long 0
+ .cfi_endproc
+ .size loseme2, . - loseme2
+
+ .section .text.main,"ax",%progbits
+ .globl main
+ .type main, %function
+main:
+ .cfi_startproc
+ .long 0
+ .cfi_endproc
+ .size main, . - main
|| [istarget or32-*-*]
|| [istarget pj*-*-*]
|| [istarget alpha-*-*]
- || [istarget hppa64-*-*]
+ || [istarget hppa*64-*-*]
|| [istarget i370-*-*]
|| [istarget i860-*-*]
|| [istarget ia64-*-*]
}
# Check if the ld used by gcc supports --gc-sections.
+ # FIXME: this test is useless since ld --help always says
+ # --gc-sections is available
set ld_output [remote_exec host $ld "--help"]
if { [ string first "--gc-sections" $ld_output ] >= 0 } {
set gc_sections_available_saved 1
return $gc_sections_available_saved
}
+# Returns true if -shared is supported on the target
+# Only used and accurate for ELF targets at the moment
+
+proc check_shared_lib_support { } {
+ if {![istarget arc-*-*]
+ && ![istarget avr-*-*]
+ && ![istarget cr16-*-*]
+ && ![istarget cris*-*-*]
+ && ![istarget crx-*-*]
+ && ![istarget d10v-*-*]
+ && ![istarget d30v-*-*]
+ && ![istarget dlx-*-*]
+ && ![istarget fr30-*-*]
+ && ![istarget frv-*-*]
+ && ![istarget h8300-*-*]
+ && ![istarget i860-*-*]
+ && ![istarget i960-*-*]
+ && ![istarget ip2k-*-*]
+ && ![istarget iq2000-*-*]
+ && ![istarget lm32-*-*]
+ && ![istarget m32c-*-*]
+ && ![istarget m32r-*-*]
+ && ![istarget m68hc1*-*-*]
+ && ![istarget mcore*-*-*]
+ && ![istarget mep-*-*]
+ && ![istarget microblaze-*-*]
+ && ![istarget mn10200-*-*]
+ && ![istarget moxie-*-*]
+ && ![istarget msp430-*-*]
+ && ![istarget mt-*-*]
+ && ![istarget openrisc-*-*]
+ && ![istarget or32-*-*]
+ && ![istarget pj-*-*]
+ && ![istarget rx-*-*]
+ && ![istarget spu-*-*]
+ && ![istarget v850*-*-*]
+ && ![istarget xstormy16-*-*]
+ && ![istarget *-*-irix*]
+ && ![istarget *-*-rtems] } {
+ return 1
+ }
+ return 0
+}
+
# Returns true if the target ld supports the plugin API.
proc check_plugin_api_available { } {
global plugin_api_available_saved