public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mail@felix-potthast.de" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug dynamic-link/31663] New: Stack not aligned at _start when calling ld.so explicitly
Date: Fri, 19 Apr 2024 22:35:06 +0000	[thread overview]
Message-ID: <bug-31663-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=31663

            Bug ID: 31663
           Summary: Stack not aligned at _start when calling ld.so
                    explicitly
           Product: glibc
           Version: 2.35
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: mail@felix-potthast.de
  Target Milestone: ---

Up to glibc version 2.35 the stack is not 16-byte aligned when the process is
entered at _start when ld.so was called explicitly.

The x86-64 SYS V ABI explicitly states it has to be aligned at that point,
though.
It also works fine when ld.so is invoked as elf interpreter.

This doesn't result in any issue most of the time because the stack
is aligned between _start and main in `sysdeps/x86_64/start.S`, for legacy
reasons probably.

I think the right place to do this alignment is at the end of ld.so.


I attached a simple example that can be build with
`gcc -nostartfiles test.S -o test`.

It runs fine when running `./test` but segfaults when running with
`/lib64/ld-linux-x86-64.so.2 ./test` due to missing stack alignment.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2024-04-19 22:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 22:35 mail@felix-potthast.de [this message]
2024-04-19 22:38 ` [Bug dynamic-link/31663] " mail@felix-potthast.de
2024-04-20  7:03 ` schwab@linux-m68k.org

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-31663-131@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).