Skip to content

[Clang] Intel Assembly Bugs (Mishandle Labels) #122200

@witbring

Description

@witbring

I am reporting an assembly bug found during research.
The tests were conducted using the latest version (Clang 19.1.0)
The issue occurs in the same way with previous versions as well.

When some register names are used in operands, Clang interprets them as
actual registers. Notably, Clang allows the creation of these labels,
which could potentially lead to problems.

  1. Example Code
.intel_syntax noprefix
.data
RAX:
RbX:
Rcx:
    .long 0
.text
test:
	mov	edx, DWORD PTR [RAX]
	mov	edx, DWORD PTR [RbX]
	mov	edx, DWORD PTR [Rcx]
    call rsP

rsP:
    ret
  1. Compilation Command
Clang -c test.c
  1. Compiled Binary Output
0000000000000000 <test>:
   0:	8b 10                	mov    edx,DWORD PTR [rax]
   2:	8b 13                	mov    edx,DWORD PTR [rbx]
   4:	8b 11                	mov    edx,DWORD PTR [rcx]
   6:	ff d4                	call   rsp

0000000000000008 <rsP>:
   8:	c3                   	ret

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions