]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld: aarch64: make EH Frame parsing aware of augmentation char 'G'
authorIndu Bhagat <indu.bhagat@oracle.com>
Mon, 25 Nov 2024 22:57:46 +0000 (14:57 -0800)
committerIndu Bhagat <indu.bhagat@oracle.com>
Fri, 11 Apr 2025 03:54:24 +0000 (20:54 -0700)
As per the DWARF for the Arm 64-bit Architecture (AArch64)
specification, the augmentation char 'G' indicates that associated
frames may modify MTE tags on the stack space they use.

Add knowledge of the 'G' augmentation char to the EH Frame parsing code.

ChangeLog:

        * bfd/elf-eh-frame.c (_bfd_elf_parse_eh_frame): Accommodate
augmentation char 'G'.
        * ld/testsuite/ld-aarch64/aarch64-elf.exp: New test.
        * ld/testsuite/ld-aarch64/mte-tagged-frame-bar.s: New test.
        * ld/testsuite/ld-aarch64/mte-tagged-frame-foo.s: New test.
        * ld/testsuite/ld-aarch64/mte-tagged-frame.d: New test.

bfd/elf-eh-frame.c
ld/testsuite/ld-aarch64/aarch64-elf.exp
ld/testsuite/ld-aarch64/mte-tagged-frame-bar.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/mte-tagged-frame-foo.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/mte-tagged-frame.d [new file with mode: 0644]

index 78b3ecb5a7db42480b382356d81d3ff6a1de58b7..53e274a7230f35caac4d6f8d9ce77b1b1e8e5c12 100644 (file)
@@ -843,6 +843,8 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
                      REQUIRE (skip_bytes (&buf, end, per_width));
                    }
                    break;
+                 case 'G':
+                   break;
                  default:
                    /* Unrecognized augmentation. Better bail out.  */
                    goto free_no_table;
index 4de498fc3817d03b649804f122af619766f233cd..2d444e7d1e26a627a2303c866e62ed6bd4e459b0 100644 (file)
@@ -376,6 +376,8 @@ run_dump_test_lp64 "variant_pcs-r"
 run_dump_test_lp64 "variant_pcs-shared"
 run_dump_test_lp64 "variant_pcs-now"
 
+run_dump_test_lp64 "mte-tagged-frame"
+
 set aarch64elflinktests {
   {"ld-aarch64/so with global symbol" "-shared" "" "" {copy-reloc-so.s}
     {} "copy-reloc-so.so"}
diff --git a/ld/testsuite/ld-aarch64/mte-tagged-frame-bar.s b/ld/testsuite/ld-aarch64/mte-tagged-frame-bar.s
new file mode 100644 (file)
index 0000000..0bd5619
--- /dev/null
@@ -0,0 +1,17 @@
+       .text
+       .global bar
+       .type bar, %function
+bar:
+       .cfi_startproc
+       .cfi_mte_tagged_frame
+        stp     x19, x20, [sp, -144]!
+        .cfi_def_cfa_offset 144
+        .cfi_offset 19, -144
+        .cfi_offset 20, -136
+        ldp     x19, x20, [sp], 144
+        .cfi_restore 20
+        .cfi_restore 19
+        .cfi_def_cfa_offset 0
+        ret
+       .cfi_endproc
+       .size bar, .-bar
diff --git a/ld/testsuite/ld-aarch64/mte-tagged-frame-foo.s b/ld/testsuite/ld-aarch64/mte-tagged-frame-foo.s
new file mode 100644 (file)
index 0000000..af5a8c4
--- /dev/null
@@ -0,0 +1,16 @@
+       .text
+       .global foo
+       .type foo, %function
+foo:
+       .cfi_startproc
+        stp     x19, x20, [sp, -32]!
+        .cfi_def_cfa_offset 32
+        .cfi_offset 19, -32
+        .cfi_offset 20, -16
+        ldp     x19, x20, [sp], 32
+        .cfi_restore 20
+        .cfi_restore 19
+        .cfi_def_cfa_offset 0
+        ret
+       .cfi_endproc
+       .size foo, .-foo
diff --git a/ld/testsuite/ld-aarch64/mte-tagged-frame.d b/ld/testsuite/ld-aarch64/mte-tagged-frame.d
new file mode 100644 (file)
index 0000000..3ec15ca
--- /dev/null
@@ -0,0 +1,29 @@
+#source: mte-tagged-frame-foo.s
+#source: mte-tagged-frame-bar.s
+#ld: -shared
+#objdump: -WF
+
+#...
+Contents of the .eh_frame section:
+
+
+0+0 0+10 0+0 CIE "zR" cf=4 df=-8 ra=30
+ +LOC +CFA +
+0+0 sp\+0 +
+
+0+14 0+20 0+18 FDE cie=0+0 pc=0+17c..0+188
+ +LOC +CFA +x19 +x20 +
+0+17c sp\+0 +u +u +
+0+180 sp\+32 +c-32  c-16 +
+0+184 sp\+0 +u +u +
+
+0+38 0+14 0+0 CIE "zRG" cf=4 df=-8 ra=30
+ +LOC +CFA +
+0+0 sp\+0 +
+
+0+50 0+1c 0+1c FDE cie=0+38 pc=0+188..0+194
+ +LOC +CFA +x19 +x20 +
+0+188 sp\+0 +u +u +
+0+18c sp\+144 +c-144 c-136 +
+0+190 sp\+0 +u +u +
+#...