Index: src/bfd/coff-i386.c =================================================================== --- src.orig/bfd/coff-i386.c 2010-03-31 10:02:15.877140000 +0200 +++ src/bfd/coff-i386.c 2010-03-31 10:03:25.820874400 +0200 @@ -195,7 +195,8 @@ static bfd_boolean in_reloc_p (abfd, how bfd * abfd ATTRIBUTE_UNUSED; reloc_howto_type *howto; { - return ! howto->pc_relative && howto->type != R_IMAGEBASE; + return ! howto->pc_relative && howto->type != R_IMAGEBASE + && howto->type != R_SECREL32; } #endif /* COFF_WITH_PE */ Index: src/bfd/coff-x86_64.c =================================================================== --- src.orig/bfd/coff-x86_64.c 2010-03-31 10:02:15.880140000 +0200 +++ src/bfd/coff-x86_64.c 2010-03-31 10:03:25.820874400 +0200 @@ -192,7 +192,8 @@ coff_amd64_reloc (bfd *abfd, static bfd_boolean in_reloc_p (bfd *abfd ATTRIBUTE_UNUSED, reloc_howto_type *howto) { - return ! howto->pc_relative && howto->type != R_AMD64_IMAGEBASE; + return ! howto->pc_relative && howto->type != R_AMD64_IMAGEBASE + && howto->type != R_AMD64_SECREL; } #endif /* COFF_WITH_PE */ @@ -555,10 +556,10 @@ coff_amd64_rtype_to_howto (bfd *abfd ATT #if defined(COFF_WITH_PE) /* Cancel out code in _bfd_coff_generic_relocate_section. */ *addendp = 0; - if (rel->r_type >= R_AMD64_PCRLONG_1 && rel->r_type <= R_AMD64_PCRLONG_5) - { - *addendp -= (bfd_vma)(rel->r_type - R_AMD64_PCRLONG); - rel->r_type = R_AMD64_PCRLONG; + if (rel->r_type >= R_AMD64_PCRLONG_1 && rel->r_type <= R_AMD64_PCRLONG_5) + { + *addendp -= (bfd_vma)(rel->r_type - R_AMD64_PCRLONG); + rel->r_type = R_AMD64_PCRLONG; } #endif Index: src/ld/testsuite/ld-pe/basefile1.s =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ src/ld/testsuite/ld-pe/basefile1.s 2010-03-31 10:42:47.888289000 +0200 @@ -0,0 +1,18 @@ +.globl _start +.globl start +.text +_start: +start: + .long 0 + +.globl _d1 +.globl _d2 +.globl _d3 +.data +_d1: + .long 1 +_d2: + .secrel32 _d3 +_d3: + .long 2 + Index: src/ld/testsuite/ld-pe/pe-basefile.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ src/ld/testsuite/ld-pe/pe-basefile.exp 2010-03-31 11:32:13.893157400 +0200 @@ -0,0 +1,89 @@ +# Expect script for complex PE tests using basefile +# Copyright 2010 +# Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. +# + +# These tests can only be run on PE/COFF platforms. +if {![is_pecoff_format]} { + return +} + +# No compiler, no test. +if { [which $CC] == 0 } { + untested "PE version scripts" + untested "aligned common tests" + # Add more "untested" directives here when adding more tests below. + return +} + +proc build_basefile1_o {} { + global CC + global CFLAGS + global srcdir + global subdir + + # Compile the object file. + if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/basefile1.s tmpdir/basefile1.o] { + fail "compiling basefile1 object" + } +} + +proc run_basefile_test { testname } { + global LD + global DLLTOOL + global srcdir + global subdir + global verbose + + if ![ld_simple_link "$LD -e start \ + --base-file=tmpdir/$testname.base \ + --export-all-symbols" tmpdir/$testname.dll \ + "tmpdir/basefile1.o"] { + fail "linking DLL" + return + } + + if { $verbose > 2 } then { verbose "output is [file_contents tmpdir/$testname.base]" 3 } + + catch "exec wc -c tmpdir/$testname.base" err + + if ![string match "0 tmpdir/$testname.base" $err] then { + send_log "$err\n" + if { $verbose == 2 } then { verbose "$err" 2 } + fail $testname + return + } + + pass "$testname" +} + + +build_basefile1_o + +if {[istarget i*86-*-cygwin*] + || [istarget i*86-*-pe] + || [istarget i*86-*-mingw*] + || [istarget x86_64-*-mingw*] } { + run_basefile_test "basefile-secrel" + } else { + untested "PE basefile test" + return + } +