aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2004-04-20 12:17:16 +0000
committerNick Clifton <nickc@redhat.com>2004-04-20 12:17:16 +0000
commit6482c264f4a6d239f2abd356e09ae465e74efeb1 (patch)
tree7ff3cb95f0c24d9341f9366e551a0e23bdb5d9bf
parentb4781d441cad5589faa6e3fcbfcfb20d28cc7579 (diff)
downloadgdb-6482c264f4a6d239f2abd356e09ae465e74efeb1.zip
gdb-6482c264f4a6d239f2abd356e09ae465e74efeb1.tar.gz
gdb-6482c264f4a6d239f2abd356e09ae465e74efeb1.tar.bz2
Add support for a .secrel32 x86 reloc to allow DWARF" debug information to used
with COFF based x86 ports.
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/bfd-in2.h3
-rw-r--r--bfd/coff-i386.c45
-rw-r--r--bfd/libbfd.h1
-rw-r--r--bfd/reloc.c5
-rw-r--r--gas/ChangeLog9
-rw-r--r--gas/config/tc-i386.c53
-rw-r--r--gas/config/tc-i386.h6
-rw-r--r--gas/testsuite/ChangeLog7
-rw-r--r--gas/testsuite/gas/i386/i386.exp7
-rw-r--r--gas/testsuite/gas/i386/secrel.d43
-rw-r--r--gas/testsuite/gas/i386/secrel.s77
-rw-r--r--include/coff/ChangeLog3
-rw-r--r--include/coff/internal.h1
-rw-r--r--ld/testsuite/ChangeLog8
-rw-r--r--ld/testsuite/ld-pe/pe.exp31
-rw-r--r--ld/testsuite/ld-pe/secrel.d27
-rw-r--r--ld/testsuite/ld-pe/secrel1.s77
-rw-r--r--ld/testsuite/ld-pe/secrel2.s14
19 files changed, 426 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index dda65cd..bff4274 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2004-04-20 DJ Delorie <dj@redhat.com>
+
+ * reloc.c: Add BFD_RELOC_32_SECREL.
+ * bfd-in2.h: Regenerate.
+ * libbfd.h: Likewise.
+ * coff-i386.c (howto_table) [COFF_WITH_PE]: Add R_SECREL32.
+ (coff_i386_rtype_to_howto) [COFF_WITH_PE]: Handle it.
+ (coff_i386_reloc_type_lookup) [COFF_WITH_PE]: Likewise.
+
2004-04-19 Jakub Jelinek <jakub@redhat.com>
* elf32-sparc.c (elf32_sparc_relocate_section): Handle
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index c2e1819..07af231 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -2027,6 +2027,9 @@ The 24-bit relocation is used in some Intel 960 configurations. */
BFD_RELOC_12_PCREL,
BFD_RELOC_8_PCREL,
+/* Section relative relocations. Some targets need this for DWARF2. */
+ BFD_RELOC_32_SECREL,
+
/* For ELF. */
BFD_RELOC_32_GOT_PCREL,
BFD_RELOC_16_GOT_PCREL,
diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c
index a24344a..e2bf860 100644
--- a/bfd/coff-i386.c
+++ b/bfd/coff-i386.c
@@ -234,7 +234,24 @@ static reloc_howto_type howto_table[] =
EMPTY_HOWTO (010),
EMPTY_HOWTO (011),
EMPTY_HOWTO (012),
+#ifdef COFF_WITH_PE
+ /* 32-bit longword section relative relocation (013). */
+ HOWTO (R_SECREL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ coff_i386_reloc, /* special_function */
+ "secrel32", /* name */
+ TRUE, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ TRUE), /* pcrel_offset */
+#else
EMPTY_HOWTO (013),
+#endif
EMPTY_HOWTO (014),
EMPTY_HOWTO (015),
EMPTY_HOWTO (016),
@@ -497,6 +514,30 @@ coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
{
*addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
}
+
+ if (rel->r_type == R_SECREL32)
+ {
+ bfd_vma osect_vma;
+
+ if (h && (h->type == bfd_link_hash_defined
+ || h->type == bfd_link_hash_defweak))
+ osect_vma = h->root.u.def.section->output_section->vma;
+ else
+ {
+ asection *sec;
+ int i;
+
+ /* Sigh, the only way to get the section to offset against
+ is to find it the hard way. */
+
+ for (sec = abfd->sections, i = 1; i < sym->n_scnum; i++)
+ sec = sec->next;
+
+ osect_vma = sec->output_section->vma;
+ }
+
+ *addendp -= osect_vma;
+ }
#endif
return howto;
@@ -525,6 +566,10 @@ coff_i386_reloc_type_lookup (abfd, code)
return howto_table + R_RELBYTE;
case BFD_RELOC_8_PCREL:
return howto_table + R_PCRBYTE;
+#ifdef COFF_WITH_PE
+ case BFD_RELOC_32_SECREL:
+ return howto_table + R_SECREL32;
+#endif
default:
BFD_FAIL ();
return 0;
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index e4e17f9..6afe58d 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -699,6 +699,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_16_PCREL",
"BFD_RELOC_12_PCREL",
"BFD_RELOC_8_PCREL",
+ "BFD_RELOC_32_SECREL",
"BFD_RELOC_32_GOT_PCREL",
"BFD_RELOC_16_GOT_PCREL",
"BFD_RELOC_8_GOT_PCREL",
diff --git a/bfd/reloc.c b/bfd/reloc.c
index cc4f6a7..59fe848 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -1647,6 +1647,11 @@ the section containing the relocation. It depends on the specific target.
The 24-bit relocation is used in some Intel 960 configurations.
ENUM
+ BFD_RELOC_32_SECREL
+ENUMDOC
+ Section relative relocations. Some targets need this for DWARF2.
+
+ENUM
BFD_RELOC_32_GOT_PCREL
ENUMX
BFD_RELOC_16_GOT_PCREL
diff --git a/gas/ChangeLog b/gas/ChangeLog
index f98a14d..9f0167c 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,12 @@
+2004-04-20 DJ Delorie <dj@redhat.com>
+
+ * config/tc-i386.h [TE_PE] (TC_CONS_FIX_NEW): Define.
+ * config/tc-i386.c (md_pseudo_table) [TE_PE]: Add "secrel32".
+ [TE_PE] (O_secrel): Define.
+ [TE_PE] (x86_pe_cons_fix_new): New.
+ [TE_PE] (pe_directive_secrel): Likewise.
+ (tc_gen_reloc) [TE_PE]: Support BFD_RELOC_32_SECREL.
+
2004-04-19 Eric Christopher <echristo@redhat.com>
* config/tc-mips.c (mips_dwarf2_addr_size): Revert part
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 5de6a55..f37c259 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -76,6 +76,9 @@ static void set_code_flag PARAMS ((int));
static void set_16bit_gcc_code_flag PARAMS ((int));
static void set_intel_syntax PARAMS ((int));
static void set_cpu_arch PARAMS ((int));
+#ifdef TE_PE
+static void pe_directive_secrel PARAMS ((int));
+#endif
static char *output_invalid PARAMS ((int c));
static int i386_operand PARAMS ((char *operand_string));
static int i386_intel_operand PARAMS ((char *operand_string, int got_a_float));
@@ -444,6 +447,9 @@ const pseudo_typeS md_pseudo_table[] =
{"att_syntax", set_intel_syntax, 0},
{"file", (void (*) PARAMS ((int))) dwarf2_directive_file, 0},
{"loc", dwarf2_directive_loc, 0},
+#ifdef TE_PE
+ {"secrel32", pe_directive_secrel, 0},
+#endif
{0, 0, 0}
};
@@ -3638,6 +3644,50 @@ x86_cons (exp, size)
}
#endif
+#ifdef TE_PE
+
+#define O_secrel (O_max + 1)
+
+void
+x86_pe_cons_fix_new (frag, off, len, exp)
+ fragS *frag;
+ unsigned int off;
+ unsigned int len;
+ expressionS *exp;
+{
+ enum bfd_reloc_code_real r = reloc (len, 0, 0, NO_RELOC);
+
+ if (exp->X_op == O_secrel)
+ {
+ exp->X_op = O_symbol;
+ r = BFD_RELOC_32_SECREL;
+ }
+
+ fix_new_exp (frag, off, len, exp, 0, r);
+}
+
+static void
+pe_directive_secrel (dummy)
+ int dummy ATTRIBUTE_UNUSED;
+{
+ expressionS exp;
+
+ do
+ {
+ expression (&exp);
+ if (exp.X_op == O_symbol)
+ exp.X_op = O_secrel;
+
+ emit_expr (&exp, 4);
+ }
+ while (*input_line_pointer++ == ',');
+
+ input_line_pointer--;
+ demand_empty_rest_of_line ();
+}
+
+#endif
+
static int i386_immediate PARAMS ((char *));
static int
@@ -5165,6 +5215,9 @@ tc_gen_reloc (section, fixp)
case BFD_RELOC_RVA:
case BFD_RELOC_VTABLE_ENTRY:
case BFD_RELOC_VTABLE_INHERIT:
+#ifdef TE_PE
+ case BFD_RELOC_32_SECREL:
+#endif
code = fixp->fx_r_type;
break;
default:
diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h
index 14b522b..5c48f58 100644
--- a/gas/config/tc-i386.h
+++ b/gas/config/tc-i386.h
@@ -408,6 +408,12 @@ extern void x86_cons_fix_new
PARAMS ((fragS *, unsigned int, unsigned int, expressionS *));
#endif
+#ifdef TE_PE
+#define TC_CONS_FIX_NEW(FRAG,OFF,LEN,EXP) x86_pe_cons_fix_new(FRAG, OFF, LEN, EXP)
+extern void x86_pe_cons_fix_new
+ PARAMS ((fragS *, unsigned int, unsigned int, expressionS *));
+#endif
+
#define DIFF_EXPR_OK /* foo-. gets turned into PC relative relocs */
#define NO_RELOC BFD_RELOC_NONE
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index c99e91f..6d6dfdf 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2004-04-20 Brian Ford <ford@vss.fsi.com>
+ DJ Delorie <dj@redhat.com>
+
+ * gas/i386/secrel.s: New test for .secrel32.
+ * gas/i386/secrel.d: Likewise.
+ * gas/i386/i386.exp: Call it for PE targets.
+
2004-04-19 Jakub Jelinek <jakub@redhat.com>
* gas/cfi/cfi-sparc64-1.d: Update.
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 3ccb7e2..946cf9e 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -88,6 +88,13 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]]
run_dump_test "tlsnopic"
}
+ # This is a PE specific test.
+ if { [istarget "*-*-cygwin*"] || [istarget "*-*-pe"]
+ || [istarget "*-*-mingw*"]
+ } then {
+ run_dump_test "secrel"
+ }
+
set ASFLAGS "$old_ASFLAGS"
}
diff --git a/gas/testsuite/gas/i386/secrel.d b/gas/testsuite/gas/i386/secrel.d
new file mode 100644
index 0000000..7df55f7
--- /dev/null
+++ b/gas/testsuite/gas/i386/secrel.d
@@ -0,0 +1,43 @@
+#objdump: -rs
+#name: i386 secrel reloc
+
+.*: +file format pe-i386
+
+RELOCATION RECORDS FOR \[\.data\]:
+OFFSET TYPE VALUE
+00000024 secrel32 \.text
+00000029 secrel32 \.text
+0000002e secrel32 \.text
+00000033 secrel32 \.text
+00000044 secrel32 \.data
+00000049 secrel32 \.data
+0000004e secrel32 \.data
+00000053 secrel32 \.data
+00000064 secrel32 \.rdata
+00000069 secrel32 \.rdata
+0000006e secrel32 \.rdata
+00000073 secrel32 \.rdata
+00000084 secrel32 ext24
+00000089 secrel32 ext2d
+0000008e secrel32 ext36
+00000093 secrel32 ext3f
+
+
+Contents of section \.text:
+ 0000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ 0010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+Contents of section \.data:
+ 0000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ 0010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ 0020 3e3e3e3e 04000000 110d0000 00111600 >>>>............
+ 0030 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+ 0040 3e3e3e3e 04000000 110d0000 00111600 >>>>............
+ 0050 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+ 0060 3e3e3e3e 04000000 110d0000 00111600 >>>>............
+ 0070 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+ 0080 3e3e3e3e 00000000 11000000 00110000 >>>>............
+ 0090 00001100 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+Contents of section \.rdata:
+ 0000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ 0010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ 0020 3e3e3e3e >>>>
diff --git a/gas/testsuite/gas/i386/secrel.s b/gas/testsuite/gas/i386/secrel.s
new file mode 100644
index 0000000..eaf59cd
--- /dev/null
+++ b/gas/testsuite/gas/i386/secrel.s
@@ -0,0 +1,77 @@
+.text
+
+ .ascii ">>>>"
+pre04: .ascii "<<<<"
+ .ascii ">>>>>"
+pre0d: .ascii "<<<"
+ .ascii ">>>>>>"
+pre16: .ascii "<<"
+ .ascii ">>>>>>>"
+pre1f: .ascii "<"
+
+.data
+
+ .ascii ">>>>"
+sam04: .ascii "<<<<"
+ .ascii ">>>>>"
+sam0d: .ascii "<<<"
+ .ascii ">>>>>>"
+sam16: .ascii "<<"
+ .ascii ">>>>>>>"
+sam1f: .ascii "<"
+
+ .ascii ">>>>"
+ .secrel32 pre04
+ .byte 0x11
+ .secrel32 pre0d
+ .byte 0x11
+ .secrel32 pre16
+ .byte 0x11
+ .secrel32 pre1f
+ .byte 0x11
+ .ascii "<<<<<<<<"
+
+ .ascii ">>>>"
+ .secrel32 sam04
+ .byte 0x11
+ .secrel32 sam0d
+ .byte 0x11
+ .secrel32 sam16
+ .byte 0x11
+ .secrel32 sam1f
+ .byte 0x11
+ .ascii "<<<<<<<<"
+
+ .ascii ">>>>"
+ .secrel32 nex04
+ .byte 0x11
+ .secrel32 nex0d
+ .byte 0x11
+ .secrel32 nex16
+ .byte 0x11
+ .secrel32 nex1f
+ .byte 0x11
+ .ascii "<<<<<<<<"
+
+ .ascii ">>>>"
+ .secrel32 ext24
+ .byte 0x11
+ .secrel32 ext2d
+ .byte 0x11
+ .secrel32 ext36
+ .byte 0x11
+ .secrel32 ext3f
+ .byte 0x11
+ .ascii "<<<<<<<<"
+
+.section .rdata
+
+ .ascii ">>>>"
+nex04: .ascii "<<<<"
+ .ascii ">>>>>"
+nex0d: .ascii "<<<"
+ .ascii ">>>>>>"
+nex16: .ascii "<<"
+ .ascii ">>>>>>>"
+nex1f: .ascii "<"
+ .ascii ">>>>"
diff --git a/include/coff/ChangeLog b/include/coff/ChangeLog
index 3316383..2c88dee 100644
--- a/include/coff/ChangeLog
+++ b/include/coff/ChangeLog
@@ -1,3 +1,6 @@
+2004-04-20 DJ Delorie <dj@redhat.com>
+
+ * internal.h (R_SECREL32): Add.
For older changes see ChangeLog-9103
diff --git a/include/coff/internal.h b/include/coff/internal.h
index 2d41bf9..710e932 100644
--- a/include/coff/internal.h
+++ b/include/coff/internal.h
@@ -607,6 +607,7 @@ struct internal_reloc
#define R_REL24 5
#define R_DIR32 6
#define R_IMAGEBASE 7
+#define R_SECREL32 11
#define R_RELBYTE 15
#define R_RELWORD 16
#define R_RELLONG 17
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 1849b20..d682835 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2004-04-14 Brian Ford <ford@vss.fsi.com>
+ DJ Delorie <dj@redhat.com>
+
+ * ld-pe/pe.exp: New, tests for i?86 PE.
+ * ld-pe/secrel1.s: New, test R_SECREL32 reloc.
+ * ld-pe/secrel2.s: Likewise.
+ * ld-pe/secrel.d: Likewise.
+
2004-04-19 Jakub Jelinek <jakub@redhat.com>
* ld-elfvsb/elfvsb.exp: XFAIL some tests on sparc64.
diff --git a/ld/testsuite/ld-pe/pe.exp b/ld/testsuite/ld-pe/pe.exp
new file mode 100644
index 0000000..cbdae79
--- /dev/null
+++ b/ld/testsuite/ld-pe/pe.exp
@@ -0,0 +1,31 @@
+# Expect script for export table in executables tests
+# Copyright 2004
+# Free Software Foundation, Inc.
+#
+# This file 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+# This test can only be run on i386 PE/COFF platforms.
+if { ![istarget i*86-*-cygwin*] && ![istarget i*86-*-pe]
+ && ![istarget i*86-*-mingw*] } {
+ return
+}
+
+set pe_tests {
+ {".secrel32" "" "" {secrel1.s secrel2.s}
+ {{objdump -s secrel.d}} "secrel.x"}
+}
+
+run_ld_link_tests $pe_tests
diff --git a/ld/testsuite/ld-pe/secrel.d b/ld/testsuite/ld-pe/secrel.d
new file mode 100644
index 0000000..9c5d9a3
--- /dev/null
+++ b/ld/testsuite/ld-pe/secrel.d
@@ -0,0 +1,27 @@
+
+tmpdir/secrel\.x: file format pei-i386
+
+Contents of section \.text:
+ 401000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ 401010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ 401020 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ 401030 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ 401040 ........ ........ ........ ........ ................
+Contents of section \.data:
+ 402000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ 402010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ 402020 3e3e3e3e 04000000 110d0000 00111600 >>>>............
+ 402030 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+ 402040 3e3e3e3e 04000000 110d0000 00111600 >>>>............
+ 402050 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+ 402060 3e3e3e3e 04000000 110d0000 00111600 >>>>............
+ 402070 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+ 402080 3e3e3e3e 24000000 112d0000 00113600 >>>>\$....-....6.
+ 402090 0000113f 00000011 3c3c3c3c 3c3c3c3c ...\?....<<<<<<<<
+Contents of section \.rdata:
+ 403000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ 403010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ 403020 3e3e3e3e >>>>
+Contents of section \.idata:
+ 404000 00000000 00000000 00000000 00000000 ................
+ 404010 00000000 ....
diff --git a/ld/testsuite/ld-pe/secrel1.s b/ld/testsuite/ld-pe/secrel1.s
new file mode 100644
index 0000000..eaf59cd
--- /dev/null
+++ b/ld/testsuite/ld-pe/secrel1.s
@@ -0,0 +1,77 @@
+.text
+
+ .ascii ">>>>"
+pre04: .ascii "<<<<"
+ .ascii ">>>>>"
+pre0d: .ascii "<<<"
+ .ascii ">>>>>>"
+pre16: .ascii "<<"
+ .ascii ">>>>>>>"
+pre1f: .ascii "<"
+
+.data
+
+ .ascii ">>>>"
+sam04: .ascii "<<<<"
+ .ascii ">>>>>"
+sam0d: .ascii "<<<"
+ .ascii ">>>>>>"
+sam16: .ascii "<<"
+ .ascii ">>>>>>>"
+sam1f: .ascii "<"
+
+ .ascii ">>>>"
+ .secrel32 pre04
+ .byte 0x11
+ .secrel32 pre0d
+ .byte 0x11
+ .secrel32 pre16
+ .byte 0x11
+ .secrel32 pre1f
+ .byte 0x11
+ .ascii "<<<<<<<<"
+
+ .ascii ">>>>"
+ .secrel32 sam04
+ .byte 0x11
+ .secrel32 sam0d
+ .byte 0x11
+ .secrel32 sam16
+ .byte 0x11
+ .secrel32 sam1f
+ .byte 0x11
+ .ascii "<<<<<<<<"
+
+ .ascii ">>>>"
+ .secrel32 nex04
+ .byte 0x11
+ .secrel32 nex0d
+ .byte 0x11
+ .secrel32 nex16
+ .byte 0x11
+ .secrel32 nex1f
+ .byte 0x11
+ .ascii "<<<<<<<<"
+
+ .ascii ">>>>"
+ .secrel32 ext24
+ .byte 0x11
+ .secrel32 ext2d
+ .byte 0x11
+ .secrel32 ext36
+ .byte 0x11
+ .secrel32 ext3f
+ .byte 0x11
+ .ascii "<<<<<<<<"
+
+.section .rdata
+
+ .ascii ">>>>"
+nex04: .ascii "<<<<"
+ .ascii ">>>>>"
+nex0d: .ascii "<<<"
+ .ascii ">>>>>>"
+nex16: .ascii "<<"
+ .ascii ">>>>>>>"
+nex1f: .ascii "<"
+ .ascii ">>>>"
diff --git a/ld/testsuite/ld-pe/secrel2.s b/ld/testsuite/ld-pe/secrel2.s
new file mode 100644
index 0000000..a1f871f
--- /dev/null
+++ b/ld/testsuite/ld-pe/secrel2.s
@@ -0,0 +1,14 @@
+.text
+
+ .ascii ">>>>"
+.global ext24
+ext24: .ascii "<<<<"
+ .ascii ">>>>>"
+.global ext2d
+ext2d: .ascii "<<<"
+ .ascii ">>>>>>"
+.global ext36
+ext36: .ascii "<<"
+ .ascii ">>>>>>>"
+.global ext3f
+ext3f: .ascii "<"