public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug dynamic-link/31662] Stack not aligned at _start when calling ld.so explicitly
Date: Sat, 20 Apr 2024 15:04:33 +0000	[thread overview]
Message-ID: <bug-31662-131-wQruo5I8wJ@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31662-131@http.sourceware.org/bugzilla/>

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.

  parent reply	other threads:[~2024-04-20 15:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 22:33 [Bug dynamic-link/31662] New: " 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31662-131-wQruo5I8wJ@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).