* [Bug dynamic-link/31662] Stack not aligned at _start when calling ld.so explicitly
2024-04-19 22:33 [Bug dynamic-link/31662] New: Stack not aligned at _start when calling ld.so explicitly mail@felix-potthast.de
@ 2024-04-20 7:03 ` schwab@linux-m68k.org
2024-04-20 7:16 ` schwab@linux-m68k.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: schwab@linux-m68k.org @ 2024-04-20 7:03 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=31662
--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
*** Bug 31663 has been marked as a duplicate of this bug. ***
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug dynamic-link/31662] Stack not aligned at _start when calling ld.so explicitly
2024-04-19 22:33 [Bug dynamic-link/31662] New: Stack not aligned at _start when calling ld.so explicitly mail@felix-potthast.de
2024-04-20 7:03 ` [Bug dynamic-link/31662] " schwab@linux-m68k.org
@ 2024-04-20 7:16 ` schwab@linux-m68k.org
2024-04-20 15:04 ` hjl.tools at gmail dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: schwab@linux-m68k.org @ 2024-04-20 7:16 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=31662
--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
At the start of a normal function, the stack pointer is always 8 mod 16, due to
the return address on the stack.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug dynamic-link/31662] Stack not aligned at _start when calling ld.so explicitly
2024-04-19 22:33 [Bug dynamic-link/31662] New: Stack not aligned at _start when calling ld.so explicitly mail@felix-potthast.de
2024-04-20 7:03 ` [Bug dynamic-link/31662] " schwab@linux-m68k.org
2024-04-20 7:16 ` schwab@linux-m68k.org
@ 2024-04-20 15:04 ` hjl.tools at gmail dot com
2024-04-21 7:27 ` mail@felix-potthast.de
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2024-04-20 15:04 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=31662
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
The assembly code doesn't align stack when calling memcpy:
[hjl@gnu-cfl-3 tmp]$ cat x.c
extern void *dest;
extern void *src;
extern void copy (void *, void *, long);
int
foo (void)
{
copy (dest, src, 5);
return 0;
}
[hjl@gnu-cfl-3 tmp]$ gcc -S -O2 x.c
[hjl@gnu-cfl-3 tmp]$ cat x.s
.file "x.c"
.text
.p2align 4
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
subq $8, %rsp <<<<<<<<<< Align stack to 16 bytes before calling
copy.
.cfi_def_cfa_offset 16
movq src(%rip), %rsi
movq dest(%rip), %rdi
movl $5, %edx
call copy
xorl %eax, %eax
addq $8, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
.ident "GCC: (GNU) 14.0.1 20240411 (Red Hat 14.0.1-0)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-cfl-3 tmp]$
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug dynamic-link/31662] Stack not aligned at _start when calling ld.so explicitly
2024-04-19 22:33 [Bug dynamic-link/31662] New: Stack not aligned at _start when calling ld.so explicitly mail@felix-potthast.de
` (2 preceding siblings ...)
2024-04-20 15:04 ` hjl.tools at gmail dot com
@ 2024-04-21 7:27 ` mail@felix-potthast.de
2024-04-21 7:53 ` schwab@linux-m68k.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mail@felix-potthast.de @ 2024-04-21 7:27 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=31662
--- Comment #4 from Felix Potthast <mail@felix-potthast.de> ---
@Andreas Schwab:
Sure, but the elf entry point is not a normal function and there is no return
address on the stack. It is not called but jumped to at the end of
_dl_start_user.
@H.J.Lu:
Yes, this is intentional. The point is: the stack pointer is guaranteed to be
16-byte aligned at process entry by the ABI. So i should'nt have to align it
before jumping into memcpy.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug dynamic-link/31662] Stack not aligned at _start when calling ld.so explicitly
2024-04-19 22:33 [Bug dynamic-link/31662] New: Stack not aligned at _start when calling ld.so explicitly mail@felix-potthast.de
` (3 preceding siblings ...)
2024-04-21 7:27 ` mail@felix-potthast.de
@ 2024-04-21 7:53 ` schwab@linux-m68k.org
2024-04-21 8:29 ` schwab@linux-m68k.org
2024-04-21 10:55 ` mail@felix-potthast.de
6 siblings, 0 replies; 8+ messages in thread
From: schwab@linux-m68k.org @ 2024-04-21 7:53 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=31662
--- Comment #5 from Andreas Schwab <schwab@linux-m68k.org> ---
Of course, that's why I wrote normal function.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug dynamic-link/31662] Stack not aligned at _start when calling ld.so explicitly
2024-04-19 22:33 [Bug dynamic-link/31662] New: Stack not aligned at _start when calling ld.so explicitly mail@felix-potthast.de
` (4 preceding siblings ...)
2024-04-21 7:53 ` schwab@linux-m68k.org
@ 2024-04-21 8:29 ` schwab@linux-m68k.org
2024-04-21 10:55 ` mail@felix-potthast.de
6 siblings, 0 replies; 8+ messages in thread
From: schwab@linux-m68k.org @ 2024-04-21 8:29 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=31662
Andreas Schwab <schwab@linux-m68k.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |2.36
Resolution|INVALID |FIXED
--- Comment #6 from Andreas Schwab <schwab@linux-m68k.org> ---
This has been fixed as a side effect of commit ec7bc492b6.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug dynamic-link/31662] Stack not aligned at _start when calling ld.so explicitly
2024-04-19 22:33 [Bug dynamic-link/31662] New: Stack not aligned at _start when calling ld.so explicitly mail@felix-potthast.de
` (5 preceding siblings ...)
2024-04-21 8:29 ` schwab@linux-m68k.org
@ 2024-04-21 10:55 ` mail@felix-potthast.de
6 siblings, 0 replies; 8+ messages in thread
From: mail@felix-potthast.de @ 2024-04-21 10:55 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=31662
--- Comment #7 from Felix Potthast <mail@felix-potthast.de> ---
Yes, this is not occurring anymore since 2.36.
2.35 is still around, though. (Ubuntu 22.04 for example)
Do you have any plans on preventing this from occurring again?
This seems to have been unnoticed.
I would suggest removing the align from `sysdeps/x86_64/start.S`. (Lines 88,89)
It goes back to 2001 when the ABI didn't explicitly state the alignment at
process
entry. It shouldn't be needed anymore and just masks bugs like this.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread