From 5e0a033bd2927a027a5fb2c93d9e403c4f505bd0 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 3 May 2021 13:28:30 +0200 Subject: [PATCH] x86: allow @secrel32 also in data definitions Now that lex_got() is uniform for all targets using it, permit COFF targets to also use @secrel32 with, in particular, .long. This is more natural than the custom .secrel32 directive, and also allows more flexibility (the "+six" form of the two added test lines doesn't work with a .secrel32 equivalent, in that it silently produces an unintended relocation type). As an extra benefit this also makes sure that data definitions in Intel syntax mode would get treated like they do for e.g. ELF targets. --- gas/ChangeLog | 8 ++++++++ gas/config/tc-i386.h | 3 ++- gas/testsuite/gas/i386/secrel.d | 6 ++++-- gas/testsuite/gas/i386/secrel.s | 12 ++++++++---- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 9442a3ea49f..0ec2886e254 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,11 @@ +2021-05-03 Jan Beulich + + * config/tc-i386.h (TC_PARSE_CONS_EXPRESSION): Adjust surrounding + #if. + * testsuite/gas/i386/secrel.s: Convert some .secrel32 to .long. + Add two further .long and an .equ. + * testsuite/gas/i386/secrel.d: Adjust expecations. + 2021-05-03 Jan Beulich * testsuite/gas/i386/secrel.d, testsuite/gas/i386/secrel.s: diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index 5516a164aa5..9ca9727d4ca 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -126,7 +126,8 @@ extern const char *i386_comment_chars; #define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_" #endif -#if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) && !defined (LEX_AT) +#if ((defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) \ + && !defined (LEX_AT)) || defined (TE_PE) #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) x86_cons (EXP, NBYTES) #endif extern bfd_reloc_code_real_type x86_cons (expressionS *, int); diff --git a/gas/testsuite/gas/i386/secrel.d b/gas/testsuite/gas/i386/secrel.d index 17530866546..f6e31c726ea 100644 --- a/gas/testsuite/gas/i386/secrel.d +++ b/gas/testsuite/gas/i386/secrel.d @@ -21,7 +21,9 @@ OFFSET[ ]+TYPE[ ]+VALUE * 0+89 secrel32 ext2d 0+8e secrel32 ext36 0+93 secrel32 ext3f -0+a2 secrel32 bar +0+a0 secrel32 \.text +0+a4 secrel32 \.text +0+aa secrel32 bar Contents of section \.text: 0000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<< @@ -37,7 +39,7 @@ Contents of section \.data: 0070 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<< 0080 3e3e3e3e 00000000 11000000 00110000 >>>>............ 0090 00001100 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<< - 00a0 8d902c00 00000000 ..,..... * + 00a0 10000000 1c000000 8d902c00 00000000 ..........,..... Contents of section \.rdata: 0000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<< 0010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>>< diff --git a/gas/testsuite/gas/i386/secrel.s b/gas/testsuite/gas/i386/secrel.s index e7de6780581..c43ad9270dd 100644 --- a/gas/testsuite/gas/i386/secrel.s +++ b/gas/testsuite/gas/i386/secrel.s @@ -27,7 +27,7 @@ sam1f: .ascii "<" .byte 0x11 .secrel32 pre16 .byte 0x11 - .secrel32 pre1f + .long pre1f@secrel32 .byte 0x11 .ascii "<<<<<<<<" @@ -36,7 +36,7 @@ sam1f: .ascii "<" .byte 0x11 .secrel32 sam0d .byte 0x11 - .secrel32 sam16 + .long sam16@secrel32 .byte 0x11 .secrel32 sam1f .byte 0x11 @@ -45,7 +45,7 @@ sam1f: .ascii "<" .ascii ">>>>" .secrel32 nex04 .byte 0x11 - .secrel32 nex0d + .long nex0d@secrel32 .byte 0x11 .secrel32 nex16 .byte 0x11 @@ -54,7 +54,7 @@ sam1f: .ascii "<" .ascii "<<<<<<<<" .ascii ">>>>" - .secrel32 ext24 + .long ext24@secrel32 .byte 0x11 .secrel32 ext2d .byte 0x11 @@ -64,6 +64,9 @@ sam1f: .ascii "<" .byte 0x11 .ascii "<<<<<<<<" + .long pre0d@secrel32+3 + .long pre16@secrel32+six + leal bar@SECREL32+44(%eax), %edx .section .rdata @@ -79,3 +82,4 @@ nex1f: .ascii "<" .ascii ">>>>" .p2align 4,0 + .equ six,6 -- 2.30.2