Skip to content

llvm assembler does not emit the correct symbol names when escaped characters are present #138390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
midnightveil opened this issue May 3, 2025 · 2 comments · Fixed by #138817
Labels
mc Machine (object) code

Comments

@midnightveil
Copy link

assembler

https://godbolt.org/z/ac1vev5nh

.type	"hello \" world", @object
"hello \" world":
    .zero	1

In GCC's as:

Symbol table '.symtab' contains 2 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 OBJECT  LOCAL  DEFAULT    1 hello " world

In Clang's as:

Symbol table '.symtab' contains 2 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 OBJECT  LOCAL  DEFAULT    2 hello \" world

c frontend

This then seems to make -save-temps have different output to without it:

https://godbolt.org/z/4sa7e5dq4

clang -save-temps main.c -o clang.o gives:

Symbol table '.symtab' contains 10 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
...
     4: 0000000000403000     4 OBJECT  GLOBAL DEFAULT    4 hello \" world
...

Without -save-temps:

Symbol table '.symtab' contains 10 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
...
     7: 0000000000403000     4 OBJECT  GLOBAL DEFAULT    4 hello " world
...
@brad0
Copy link
Contributor

brad0 commented May 7, 2025

cc @MaskRay

@MaskRay MaskRay closed this as completed in 87db094 May 8, 2025
petrhosek pushed a commit to petrhosek/llvm-project that referenced this issue May 8, 2025
gas has supported " quoted symbols since 2015:
https://sourceware.org/pipermail/binutils/2015-August/090003.html

We don't handle \\ or \" , leading to clang -c --save-temps vs clang -c
difference for the following C code:

```
int x asm("a\"\\b");
```

Fix llvm#138390

MC/COFF/safeseh.h looks incorrect. \01 in `.safeseh "\01foo"` is not a
correct escape sequence. Change it to \\

Pull Request: llvm#138817
@EugeneZelenko EugeneZelenko added mc Machine (object) code and removed new issue labels May 8, 2025
@joker-eph joker-eph reopened this May 9, 2025
@joker-eph
Copy link
Collaborator

Reopen due to revert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mc Machine (object) code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants