Issue 120871
Summary pushsection idiom for GDB scripts not supported by integrated `as` and llvm-mc for arm targets
Labels new issue
Assignees
Reporter lf-
    ```
$ armv7l-unknown-linux-gnueabihf-cc test.c
<inline asm>:1:41: error: expected '%<type>' or "<type>"
    1 | .pushsection ".debug_gdb_scripts", "MS",@progbits,1
      |                                         ^
<inline asm>:4:12: error: .popsection without corresponding .pushsection
    4 | .popsection
      |            ^
2 errors generated.
$ armv7l-unknown-linux-gnueabihf-cc -no-integrated-as test.c
<completes successfully>
```

There is an assembly idiom as follows which works with both `-no-integrated-as` and `-integrated-as` on the Clang x86 target, but not on the armv7 target. This causes some build breakage of code using this idiom which is accepted by GNU `as` and Clang with `-no-integrated-as`.

Code:
```c
asm (
".pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n"
".byte 1 /* Python */\n"
".asciz \"whatkillsusmakesusdeader.py\"\n"
".popsection");

int main(void) {
}
```

Repro using llvm-mc:

```asm
.pushsection ".debug_gdb_scripts", "MS",@progbits,1
.byte 1 /* Python */
.asciz "whatkillsusmakesusdeader.py"
.popsection
```

```
$ llvm-mc --arch=x86 /tmp/test.s
        .text
        .section        .debug_gdb_scripts,"MS",@progbits,1
        .byte   1
        .ascii  "whatkillsusmakesusdeader.py"
        .byte   0
        .text

$ llvm-mc --arch=arm /tmp/test.s
        .text
/tmp/test.s:1:41: error: expected '%<type>' or "<type>"
.pushsection ".debug_gdb_scripts", "MS",@progbits,1
                                        ^
        .byte   1
        .ascii  "whatkillsusmakesusdeader.py"
        .byte   0
/tmp/test.s:4:12: error: .popsection without corresponding .pushsection
.popsection
           ^
```

Compare:

```
$ » armv7l-unknown-linux-gnueabihf-as test.s                                        
$ » armv7l-unknown-linux-gnueabihf-as --version
GNU assembler (GNU Binutils) 2.43.1
Copyright (C) 2024 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `armv7l-unknown-linux-gnueabihf'.
```



```
$ armv7l-unknown-linux-gnueabihf-cc --version               
clang version 18.1.8
Target: armv7l-unknown-linux-gnueabihf
Thread model: posix
InstalledDir: /nix/store/02xcipa0v0dc1qv9kdihdkffq7crsjr6-clang-18.1.8/bin
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to