public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/116472] New: Wrong offset format when generating assembly with -S and -masm=intel
@ 2024-08-23 13:49 8dcc.git at gmail dot com
2024-08-23 19:15 ` [Bug target/116472] " pinskia at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: 8dcc.git at gmail dot com @ 2024-08-23 13:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116472
Bug ID: 116472
Summary: Wrong offset format when generating assembly with -S
and -masm=intel
Product: gcc
Version: 14.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: 8dcc.git at gmail dot com
Target Milestone: ---
The following C code:
#include <stdio.h>
int main(void) {
int arr[2];
arr[0] = 123;
arr[1] = 456;
printf("%d, %d\n", arr[0], arr[1]);
return 0;
}
Is compiled with:
gcc -S -masm=intel -o output.s source.c
This is a chunk of the generated assembly in output.s:
...
mov QWORD PTR -8[rbp], rax
xor eax, eax
mov DWORD PTR -16[rbp], 123
mov DWORD PTR -12[rbp], 456
...
As far as I know, in intel syntax the offset of the effective addresses should
be inside the square brackets, next to the register:
...
mov QWORD PTR [rbp-8], rax
xor eax, eax
mov DWORD PTR [rbp-16], 123
mov DWORD PTR [rbp-12], 456
...
---------------------------------------------
My GCC version:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust
--enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.1 20240805 (GCC)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/116472] Wrong offset format when generating assembly with -S and -masm=intel
2024-08-23 13:49 [Bug other/116472] New: Wrong offset format when generating assembly with -S and -masm=intel 8dcc.git at gmail dot com
@ 2024-08-23 19:15 ` pinskia at gcc dot gnu.org
2024-08-23 19:18 ` [Bug target/116472] Wrong offset format when generating assembly with -masm=intel and -fPIE/-fPIC pinskia at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-23 19:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116472
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2024-08-23
Status|UNCONFIRMED |WAITING
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I can't reproduce this with the trunk nor with GCC 14, I get:
```
main:
.LFB0:
.cfi_startproc
lea ecx, [esp+4]
.cfi_def_cfa 1, 0
and esp, -16
push DWORD PTR [ecx-4]
push ebp
mov ebp, esp
.cfi_escape 0x10,0x5,0x2,0x75,0
push ecx
.cfi_escape 0xf,0x3,0x75,0x7c,0x6
sub esp, 20
mov DWORD PTR [ebp-16], 123
mov DWORD PTR [ebp-12], 456
mov edx, DWORD PTR [ebp-12]
mov eax, DWORD PTR [ebp-16]
sub esp, 4
push edx
push eax
push OFFSET FLAT:.LC0
call printf
add esp, 16
mov eax, 0
mov ecx, DWORD PTR [ebp-4]
.cfi_def_cfa 1, 0
leave
.cfi_restore 5
lea esp, [ecx-4]
.cfi_def_cfa 4, 4
ret
```
Are you sure you don't have some patch which breaks this?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/116472] Wrong offset format when generating assembly with -masm=intel and -fPIE/-fPIC
2024-08-23 13:49 [Bug other/116472] New: Wrong offset format when generating assembly with -S and -masm=intel 8dcc.git at gmail dot com
2024-08-23 19:15 ` [Bug target/116472] " pinskia at gcc dot gnu.org
@ 2024-08-23 19:18 ` pinskia at gcc dot gnu.org
2024-08-24 15:09 ` 8dcc.git at gmail dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-23 19:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116472
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Wrong offset format when |Wrong offset format when
|generating assembly with -S |generating assembly with
|and -masm=intel |-masm=intel and -fPIE/-fPIC
Status|WAITING |UNCONFIRMED
Ever confirmed|1 |0
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Oh -fPIE is needed to get the "broken" assembly.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/116472] Wrong offset format when generating assembly with -masm=intel and -fPIE/-fPIC
2024-08-23 13:49 [Bug other/116472] New: Wrong offset format when generating assembly with -S and -masm=intel 8dcc.git at gmail dot com
2024-08-23 19:15 ` [Bug target/116472] " pinskia at gcc dot gnu.org
2024-08-23 19:18 ` [Bug target/116472] Wrong offset format when generating assembly with -masm=intel and -fPIE/-fPIC pinskia at gcc dot gnu.org
@ 2024-08-24 15:09 ` 8dcc.git at gmail dot com
2024-08-24 16:04 ` xry111 at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: 8dcc.git at gmail dot com @ 2024-08-24 15:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116472
--- Comment #3 from 8dcc.git at gmail dot com ---
> Are you sure you don't have some patch which breaks this?
I haven't manually patched GCC, it was installed it from the Arch repository,
which is apparently configured with `--enable-default-pie`, according to `gcc
-v`.
> Oh -fPIE is needed to get the "broken" assembly.
I tried compiling the source with:
gcc -S -masm=intel -no-pie -o output.s source.c
And the issue still persists.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/116472] Wrong offset format when generating assembly with -masm=intel and -fPIE/-fPIC
2024-08-23 13:49 [Bug other/116472] New: Wrong offset format when generating assembly with -S and -masm=intel 8dcc.git at gmail dot com
` (2 preceding siblings ...)
2024-08-24 15:09 ` 8dcc.git at gmail dot com
@ 2024-08-24 16:04 ` xry111 at gcc dot gnu.org
2024-08-25 7:53 ` rguenth at gcc dot gnu.org
2024-08-25 17:20 ` 8dcc.git at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: xry111 at gcc dot gnu.org @ 2024-08-24 16:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116472
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #4 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to 8dcc.git from comment #3)
> > Are you sure you don't have some patch which breaks this?
> I haven't manually patched GCC, it was installed it from the Arch
> repository, which is apparently configured with `--enable-default-pie`,
> according to `gcc -v`.
>
> > Oh -fPIE is needed to get the "broken" assembly.
> I tried compiling the source with:
>
> gcc -S -masm=intel -no-pie -o output.s source.c
>
> And the issue still persists.
-no-pie is only passed through to the linker. The compiler option is -fno-PIE.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/116472] Wrong offset format when generating assembly with -masm=intel and -fPIE/-fPIC
2024-08-23 13:49 [Bug other/116472] New: Wrong offset format when generating assembly with -S and -masm=intel 8dcc.git at gmail dot com
` (3 preceding siblings ...)
2024-08-24 16:04 ` xry111 at gcc dot gnu.org
@ 2024-08-25 7:53 ` rguenth at gcc dot gnu.org
2024-08-25 17:20 ` 8dcc.git at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-08-25 7:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116472
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target|X86_64 |x86_64-*-*
Last reconfirmed|2024-08-23 00:00:00 |2024-08-25
Keywords| |assemble-failure
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed with -fPIE, though gas happily accepts the DWORD PTR -8[rbp] form.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/116472] Wrong offset format when generating assembly with -masm=intel and -fPIE/-fPIC
2024-08-23 13:49 [Bug other/116472] New: Wrong offset format when generating assembly with -S and -masm=intel 8dcc.git at gmail dot com
` (4 preceding siblings ...)
2024-08-25 7:53 ` rguenth at gcc dot gnu.org
@ 2024-08-25 17:20 ` 8dcc.git at gmail dot com
5 siblings, 0 replies; 7+ messages in thread
From: 8dcc.git at gmail dot com @ 2024-08-25 17:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116472
--- Comment #6 from 8dcc.git at gmail dot com ---
(In reply to Xi Ruoyao from comment #4)
> > I tried compiling the source with:
> >
> > gcc -S -masm=intel -no-pie -o output.s source.c
> >
> > And the issue still persists.
>
> -no-pie is only passed through to the linker. The compiler option is -fno-PIE.
You are right. And yes, when compiling with -fno-PIE instead of -no-pie, the
issue does not happen.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-08-25 17:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-23 13:49 [Bug other/116472] New: Wrong offset format when generating assembly with -S and -masm=intel 8dcc.git at gmail dot com
2024-08-23 19:15 ` [Bug target/116472] " pinskia at gcc dot gnu.org
2024-08-23 19:18 ` [Bug target/116472] Wrong offset format when generating assembly with -masm=intel and -fPIE/-fPIC pinskia at gcc dot gnu.org
2024-08-24 15:09 ` 8dcc.git at gmail dot com
2024-08-24 16:04 ` xry111 at gcc dot gnu.org
2024-08-25 7:53 ` rguenth at gcc dot gnu.org
2024-08-25 17:20 ` 8dcc.git at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).