Index: bfd/elf32-s390.c =================================================================== --- bfd/elf32-s390.c.orig 2010-10-25 17:54:14.000000000 +0200 +++ bfd/elf32-s390.c 2011-01-10 17:46:32.000000000 +0100 @@ -2504,13 +2504,34 @@ elf_s390_relocate_section (output_bfd, i unresolved_reloc = FALSE; break; - case R_390_8: - case R_390_16: - case R_390_32: case R_390_PC16: case R_390_PC16DBL: case R_390_PC32DBL: case R_390_PC32: + /* This is strictly required only for PC32DBL, which + is not handled by ld.so, but let's be helpful to the user also + in the other cases. */ + if (info->shared + && !SYMBOL_REFERENCES_LOCAL (info, h) + && (input_section->flags & SEC_ALLOC) != 0 + && (input_section->flags & SEC_READONLY) != 0 + && (!h->def_regular + || r_type != R_390_PC32DBL + || h->type != STT_FUNC + || ELF_ST_VISIBILITY (h->other) != STV_PROTECTED)) + { + (*_bfd_error_handler) + (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"), + input_bfd, elf_howto_table[r_type].name, + h->root.root.string); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + /* Fall through. */ + + case R_390_8: + case R_390_16: + case R_390_32: if ((input_section->flags & SEC_ALLOC) == 0) break; Index: bfd/elf64-s390.c =================================================================== --- bfd/elf64-s390.c.orig 2010-10-25 17:54:15.000000000 +0200 +++ bfd/elf64-s390.c 2011-01-10 17:46:32.000000000 +0100 @@ -2497,15 +2497,36 @@ elf_s390_relocate_section (bfd *output_b unresolved_reloc = FALSE; break; - case R_390_8: - case R_390_16: - case R_390_32: - case R_390_64: case R_390_PC16: case R_390_PC16DBL: case R_390_PC32: case R_390_PC32DBL: case R_390_PC64: + /* This is strictly required only for PC32DBL, which + is not handled by ld.so, but let's be helpful to the user also + in the other cases. */ + if (info->shared + && !SYMBOL_REFERENCES_LOCAL (info, h) + && (input_section->flags & SEC_ALLOC) != 0 + && (input_section->flags & SEC_READONLY) != 0 + && (!h->def_regular + || r_type != R_390_PC32DBL + || h->type != STT_FUNC + || ELF_ST_VISIBILITY (h->other) != STV_PROTECTED)) + { + (*_bfd_error_handler) + (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"), + input_bfd, elf_howto_table[r_type].name, + h->root.root.string); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + /* Fall through. */ + + case R_390_8: + case R_390_16: + case R_390_32: + case R_390_64: if ((input_section->flags & SEC_ALLOC) == 0) break; Index: ld/testsuite/ld-elfvers/vers.exp =================================================================== --- ld/testsuite/ld-elfvers/vers.exp.orig 2010-11-05 04:54:21.000000000 +0100 +++ ld/testsuite/ld-elfvers/vers.exp 2011-01-10 17:47:22.000000000 +0100 @@ -97,6 +97,7 @@ if [istarget mips*-*-*] { case $target_triplet in { { ia64-*-* } { set as_options "-x" } + { s390-*-linux-* } { set as_options "-march=z900" } { sparc-*-* } { set as_options "-Av9a" } default { set as_options "" } } @@ -768,8 +769,9 @@ proc build_exec { test source execname f pass $test } -if [istarget x86_64-*-linux*] { - # x86_64 doesn't like non-pic shared libraries +if { [istarget x86_64-*-linux*] \ + || [istarget s390*-*-linux*] } { + # x86_64 and s390 don't like non-pic shared libraries set pic "yes" } else { set pic "no" Index: ld/testsuite/ld-elfvsb/elfvsb.exp =================================================================== --- ld/testsuite/ld-elfvsb/elfvsb.exp.orig 2010-02-09 11:46:26.000000000 +0100 +++ ld/testsuite/ld-elfvsb/elfvsb.exp 2011-01-10 17:46:32.000000000 +0100 @@ -292,6 +292,7 @@ proc visibility_run {visibility} { setup_xfail "sparc*-*-linux*" } } + setup_xfail "s390*-*-linux*" setup_xfail "x86_64-*-linux*" if { ![istarget hppa*64*-*-linux*] } { setup_xfail "hppa*-*-linux*" @@ -333,6 +334,7 @@ proc visibility_run {visibility} { setup_xfail "alpha*-*-linux*" setup_xfail "mips*-*-linux*" } + setup_xfail "s390*-*-linux*" setup_xfail "x86_64-*-linux*" if { ![istarget hppa*64*-*-linux*] } { setup_xfail "hppa*-*-linux*" @@ -402,6 +404,7 @@ proc visibility_run {visibility} { setup_xfail "sparc*-*-linux*" } } + setup_xfail "s390*-*-linux*" setup_xfail "x86_64-*-linux*" if { ![istarget hppa*64*-*-linux*] } { setup_xfail "hppa*-*-linux*" Index: ld/testsuite/ld-shared/shared.exp =================================================================== --- ld/testsuite/ld-shared/shared.exp.orig 2010-10-28 11:08:35.000000000 +0200 +++ ld/testsuite/ld-shared/shared.exp 2011-01-10 17:48:12.000000000 +0100 @@ -234,7 +234,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $ setup_xfail "sparc*-*-linux*" } setup_xfail "x86_64-*-linux*" - setup_xfail "s390x-*-linux*" + setup_xfail "s390*-*-linux*" if [ string match $shared_needs_pic "yes" ] { setup_xfail "arm*-*-linux*" } @@ -257,7 +257,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $ setup_xfail "sparc*-*-linux*" } setup_xfail "x86_64-*-linux*" - setup_xfail "s390x-*-linux*" + setup_xfail "s390*-*-linux*" if [ string match $shared_needs_pic "yes" ] { setup_xfail "arm*-*-linux*" } @@ -310,7 +310,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG $p setup_xfail "sparc*-*-linux*" } setup_xfail "x86_64-*-linux*" - setup_xfail "s390x-*-linux*" + setup_xfail "s390*-*-linux*" if [ string match $shared_needs_pic "yes" ] { setup_xfail "arm*-*-linux*" }