diff options
author | Cui, Lili <lili.cui@intel.com> | 2024-09-19 14:38:16 +0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2024-09-21 05:19:16 +0800 |
commit | d774bf9b3623239a1cfa729afcf048a15da657d3 (patch) | |
tree | 847634d920f3df46b1872fa558bff2adbef01bb6 /ld/testsuite | |
parent | ae6a4c3f1d5caeba962d2c1748a8d2b3bebb1007 (diff) | |
download | gdb-d774bf9b3623239a1cfa729afcf048a15da657d3.zip gdb-d774bf9b3623239a1cfa729afcf048a15da657d3.tar.gz gdb-d774bf9b3623239a1cfa729afcf048a15da657d3.tar.bz2 |
x86: Add tls check in gas
Assembler shouldn't accept invalid TLS instructions, TLS relocations
can only be used with specific instructions as specified in TLS psABI
and linker issues an error when TLS relocations are used with wrong
instructions or format. Since it is inconvenient for gcc to rely on
linker to report errors, adding TLS check in the assembler stage so
that gcc can know TLS errors earlier.
gas/ChangeLog:
PR gas/32022
* config.in: Regenerate.
* config/tc-i386.c
*(enum x86_tls_error_type): New.
*(struct _i386_insn): Added has_gotrel to indicate whether TLS
relocations need to be checked.
(x86_check_tls_relocation): Added a new function to check TLS
relocation.
(x86_report_tls_error): Created a new function to report TLS error.
(i386_assemble): Handle x86_check_tls_relocation.
(lex_got): Set i.has_gotrel.
(OPTION_MTLS_CHECK): Added a new option to contrl TLS check.
(struct option): Ditto.
(md_parse_option): Ditto.
(md_show_usage): Ditto.
* configure.ac: Added a new option to check TLS relocation by
default.
* configure: Regenerated.
* doc/c-i386.texi: Document -mtls-check=.
* testsuite/gas/i386/i386.exp: Added new tests.
* testsuite/gas/i386/ilp32/ilp32.exp: Ditto.
* testsuite/gas/i386/ilp32/reloc64.d: Disable TLS check for it.
* testsuite/gas/i386/ilp32/x32-tls.d: Ditto.
* testsuite/gas/i386/inval-tls.l: Added more test cases.
* testsuite/gas/i386/inval-tls.s: Ditto.
* testsuite/gas/i386/reloc32.d: Disable TLS check for it.
* testsuite/gas/i386/reloc64.d: Ditto.
* testsuite/gas/i386/x86-64-inval-tls.l: Added more test cases.
* testsuite/gas/i386/x86-64-inval-tls.s: Ditto.
* testsuite/gas/i386/x86-64.exp: Added new tests.
* testsuite/gas/i386/ilp32/x32-inval-tls.l: New test.
* testsuite/gas/i386/ilp32/x32-inval-tls.s: Ditto.
* testsuite/gas/i386/ilp32/x86-64-tls.d: Ditto.
* testsuite/gas/i386/tls.d: Ditto.
* testsuite/gas/i386/tls.s: Ditto.
* testsuite/gas/i386/x86-64-tls.d: Ditto.
* testsuite/gas/i386/x86-64-tls.s: Ditto.
ld/ChangeLog:
PR gas/32022
* testsuite/ld-i386/tlsgdesc1.d: Disable TLS check for it.
* testsuite/ld-i386/tlsgdesc2.d: Ditto.
* testsuite/ld-i386/tlsie2.d: Ditto.
* testsuite/ld-i386/tlsie3.d: Ditto.
* testsuite/ld-i386/tlsie4.d: Ditto.
* testsuite/ld-i386/tlsie5.d: Ditto.
* testsuite/ld-i386/tlsgdesc3.d: Ditto.
* testsuite/ld-x86-64/tlsdesc3.d: Ditto.
* testsuite/ld-x86-64/tlsdesc4.d: Ditto.
* testsuite/ld-x86-64/tlsie2.d: Ditto.
* testsuite/ld-x86-64/tlsie3.d: Ditto.
* testsuite/ld-x86-64/tlsie5.d: Ditto.
* testsuite/ld-x86-64/tlsdesc5.d: Ditto.
Diffstat (limited to 'ld/testsuite')
-rw-r--r-- | ld/testsuite/ld-i386/tlsgdesc1.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/tlsgdesc2.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/tlsgdesc3.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/tlsie2.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/tlsie3.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/tlsie4.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/tlsie5.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/tlsdesc3.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/tlsdesc4.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/tlsdesc5.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/tlsie2.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/tlsie3.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/tlsie5.d | 2 |
13 files changed, 13 insertions, 13 deletions
diff --git a/ld/testsuite/ld-i386/tlsgdesc1.d b/ld/testsuite/ld-i386/tlsgdesc1.d index 2a70e81..0c853ab 100644 --- a/ld/testsuite/ld-i386/tlsgdesc1.d +++ b/ld/testsuite/ld-i386/tlsgdesc1.d @@ -1,4 +1,4 @@ #name: TLS GDesc->LE transition check (LEA) -#as: --32 +#as: --32 -mtls-check=no #ld: -melf_i386 #error: .*: relocation R_386_TLS_GOTDESC against `foo' must be used in LEA only diff --git a/ld/testsuite/ld-i386/tlsgdesc2.d b/ld/testsuite/ld-i386/tlsgdesc2.d index bbf93be..99e1b18 100644 --- a/ld/testsuite/ld-i386/tlsgdesc2.d +++ b/ld/testsuite/ld-i386/tlsgdesc2.d @@ -1,4 +1,4 @@ #name: TLS GDesc->LE transition check (indirect CALL) -#as: --32 +#as: --32 -mtls-check=no #ld: -melf_i386 #error: .*: relocation R_386_TLS_DESC_CALL against `foo' must be used in indirect CALL with EAX register only diff --git a/ld/testsuite/ld-i386/tlsgdesc3.d b/ld/testsuite/ld-i386/tlsgdesc3.d index f2c29d8..4bb99c4 100644 --- a/ld/testsuite/ld-i386/tlsgdesc3.d +++ b/ld/testsuite/ld-i386/tlsgdesc3.d @@ -1,5 +1,5 @@ #source: tlsgdesc2.s #name: TLS GDesc call (indirect CALL) -#as: --32 +#as: --32 -mtls-check=no #ld: -shared -melf_i386 #error: .*: relocation R_386_TLS_DESC_CALL against `foo' must be used in indirect CALL with EAX register only diff --git a/ld/testsuite/ld-i386/tlsie2.d b/ld/testsuite/ld-i386/tlsie2.d index 9f9e630..4e7dc6e 100644 --- a/ld/testsuite/ld-i386/tlsie2.d +++ b/ld/testsuite/ld-i386/tlsie2.d @@ -1,4 +1,4 @@ #name: TLS IE->LE transition check (R_386_TLS_GOTIE with %eax) -#as: --32 +#as: --32 -mtls-check=no #ld: -melf_i386 #error: .*: relocation R_386_TLS_GOTIE against `foo' must be used in ADD, SUB or MOV only diff --git a/ld/testsuite/ld-i386/tlsie3.d b/ld/testsuite/ld-i386/tlsie3.d index 506f1a0..6bfc78e 100644 --- a/ld/testsuite/ld-i386/tlsie3.d +++ b/ld/testsuite/ld-i386/tlsie3.d @@ -1,4 +1,4 @@ #name: TLS IE->LE transition check (R_386_TLS_GOTIE) -#as: --32 +#as: --32 -mtls-check=no #ld: -melf_i386 #error: .*: relocation R_386_TLS_GOTIE against `foo' must be used in ADD, SUB or MOV only diff --git a/ld/testsuite/ld-i386/tlsie4.d b/ld/testsuite/ld-i386/tlsie4.d index a516d00..98293f4 100644 --- a/ld/testsuite/ld-i386/tlsie4.d +++ b/ld/testsuite/ld-i386/tlsie4.d @@ -1,4 +1,4 @@ #name: TLS IE->LE transition check (R_386_TLS_IE with %eax) -#as: --32 +#as: --32 -mtls-check=no #ld: -melf_i386 #error: .*: relocation R_386_TLS_IE against `foo' must be used in ADD or MOV only diff --git a/ld/testsuite/ld-i386/tlsie5.d b/ld/testsuite/ld-i386/tlsie5.d index d344718..4e9c9a8 100644 --- a/ld/testsuite/ld-i386/tlsie5.d +++ b/ld/testsuite/ld-i386/tlsie5.d @@ -1,4 +1,4 @@ #name: TLS IE->LE transition check (R_386_TLS_IE) -#as: --32 +#as: --32 -mtls-check=no #ld: -melf_i386 #error: .*: relocation R_386_TLS_IE against `foo' must be used in ADD or MOV only diff --git a/ld/testsuite/ld-x86-64/tlsdesc3.d b/ld/testsuite/ld-x86-64/tlsdesc3.d index bbf22eb..9558848 100644 --- a/ld/testsuite/ld-x86-64/tlsdesc3.d +++ b/ld/testsuite/ld-x86-64/tlsdesc3.d @@ -1,4 +1,4 @@ #name: TLS GDesc->LE transition check (LEA) -#as: --64 +#as: --64 -mtls-check=no #ld: -melf_x86_64 #error: .*: relocation R_X86_64_GOTPC32_TLSDESC against `foo' must be used in LEA only diff --git a/ld/testsuite/ld-x86-64/tlsdesc4.d b/ld/testsuite/ld-x86-64/tlsdesc4.d index c882c87..ccaa525 100644 --- a/ld/testsuite/ld-x86-64/tlsdesc4.d +++ b/ld/testsuite/ld-x86-64/tlsdesc4.d @@ -1,4 +1,4 @@ #name: TLS GDesc->LE transition check (indirect CALL) -#as: --64 +#as: --64 -mtls-check=no #ld: -melf_x86_64 #error: .*: relocation R_X86_64_TLSDESC_CALL against `foo' must be used in indirect CALL with RAX register only diff --git a/ld/testsuite/ld-x86-64/tlsdesc5.d b/ld/testsuite/ld-x86-64/tlsdesc5.d index 6a0158b..0876993 100644 --- a/ld/testsuite/ld-x86-64/tlsdesc5.d +++ b/ld/testsuite/ld-x86-64/tlsdesc5.d @@ -1,5 +1,5 @@ #source: tlsdesc4.s #name: TLS GDesc call (indirect CALL) -#as: --64 +#as: --64 -mtls-check=no #ld: -shared -melf_x86_64 #error: .*: relocation R_X86_64_TLSDESC_CALL against `foo' must be used in indirect CALL with RAX register only diff --git a/ld/testsuite/ld-x86-64/tlsie2.d b/ld/testsuite/ld-x86-64/tlsie2.d index bf8a819..2e6d41c 100644 --- a/ld/testsuite/ld-x86-64/tlsie2.d +++ b/ld/testsuite/ld-x86-64/tlsie2.d @@ -1,4 +1,4 @@ #name: TLS IE->LE transition check -#as: --64 +#as: --64 -mtls-check=no #ld: -melf_x86_64 #error: .*: relocation R_X86_64_GOTTPOFF against `foo' must be used in ADD or MOV only diff --git a/ld/testsuite/ld-x86-64/tlsie3.d b/ld/testsuite/ld-x86-64/tlsie3.d index 49d8464..b59cc64 100644 --- a/ld/testsuite/ld-x86-64/tlsie3.d +++ b/ld/testsuite/ld-x86-64/tlsie3.d @@ -1,4 +1,4 @@ #name: TLS IE->LE transition check (%r12) -#as: --64 +#as: --64 -mtls-check=no #ld: -melf_x86_64 #error: .*: relocation R_X86_64_GOTTPOFF against `foo' must be used in ADD or MOV only diff --git a/ld/testsuite/ld-x86-64/tlsie5.d b/ld/testsuite/ld-x86-64/tlsie5.d index 29de1ce..d7ab5ab 100644 --- a/ld/testsuite/ld-x86-64/tlsie5.d +++ b/ld/testsuite/ld-x86-64/tlsie5.d @@ -1,4 +1,4 @@ #name: TLS IE->LE transition check (APX) -#as: --64 +#as: --64 -mtls-check=no #ld: -melf_x86_64 #error: .*: relocation R_X86_64_CODE_6_GOTTPOFF against `foo' must be used in ADD only |