From eac4eb8ecb2626ef7711d8f6bee9e870ae435604 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 6 Apr 2021 13:27:50 +0100 Subject: Fix a problem assembling AArch64 sources when a relocation is generated against a symbol that has a defined value. PR 27217 * config/tc-aarch64.c (my_get_expression): Rename to aarch64_get_expression. Add a fifth argument to enable deferring of expression resolution. (parse_typed_reg): Update calls to my_get_expression. (parse_vector_reg_list): Likewise. (parse_immediate_expression): Likewise. (parse_big_immediate): Likewise. (parse_shift): Likewise. (parse_shifter_operand_imm): Likewise. (parse_operands): Likewise. (parse_shifter_operand_reloc): Update calls to my_get_expression and call aarch64_force_reloc to determine the value of the new fifth argument. (parse_address_main): Likewise. (parse_half): Likewise. (parse_adrp): Likewise. (aarch64_force_reloc): New function. Contains code extracted from... (aarch64_force_relocation): ... here. * testsuite/gas/aarch64/pr27217.s: New test case. * testsuite/gas/aarch64/pr27217.d: New test driver. --- gas/testsuite/gas/aarch64/pr27217.d | 15 +++++++++++++++ gas/testsuite/gas/aarch64/pr27217.s | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 gas/testsuite/gas/aarch64/pr27217.d create mode 100644 gas/testsuite/gas/aarch64/pr27217.s (limited to 'gas/testsuite') diff --git a/gas/testsuite/gas/aarch64/pr27217.d b/gas/testsuite/gas/aarch64/pr27217.d new file mode 100644 index 0000000..4645ff5 --- /dev/null +++ b/gas/testsuite/gas/aarch64/pr27217.d @@ -0,0 +1,15 @@ +# Check that expressions that generate relocations work when the symbol is a constant. +#name: PR27212 +#objdump: -rd + +.*: file format .* + +Disassembly of section \.text: + +0+000 <.*>: +[ ]+0:[ ]+90000000[ ]+adrp[ ]+x0, 12345678[ ]+ +[ ]+0:[ ]+R_AARCH64_ADR_PREL_PG_HI21[ ]+bar +[ ]+4:[ ]+91000000[ ]+add[ ]+x0, x0, #0x0 +[ ]+4:[ ]+R_AARCH64_ADD_ABS_LO12_NC[ ]+bar +[ ]+8:[ ]+d65f03c0[ ]+ret +#pass diff --git a/gas/testsuite/gas/aarch64/pr27217.s b/gas/testsuite/gas/aarch64/pr27217.s new file mode 100644 index 0000000..8cb9230 --- /dev/null +++ b/gas/testsuite/gas/aarch64/pr27217.s @@ -0,0 +1,16 @@ + .arch armv8-a + .file "set.c" + .text + // Start of user assembly + .set bar, 0x12345678 + // End of user assembly + .align 2 + .p2align 4,,11 + .global foo + .type foo, %function +foo: + adrp x0, bar + add x0, x0, :lo12:bar + ret + .size foo, .-foo + .ident "GCC: (GNU) 10.2.1 20201030 (RTEMS 6, RSB " -- cgit v1.1