https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108337

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
int main(int argc, char *argv[])
{
    int i = 0;
    char msg[65] = "Hello World 0!\n";

    auto result = write(1, msg, sizeof(msg) - 1);
    i = 0;
    uintptr_t t;
    asm("mov %%rsp, %0":"=r"(t));
    while (i < 64) {
        uintptr_t tt = (t >> i) & 0xf;
        msg[(64-i-1)] = (tt > 9) ? (tt - 10 + 'a') : (tt + '0');
        i++;
    }
    result = write(1, msg, sizeof(msg) - 1);
    exit(result >= 0 ? 0 : 1);
}

Gives:
00000000000000000137fffffffffffeda5b6db6da5a49248124925b7eda5a48
For  -static -nostartfiles -nostdlib -Wl,-emain without gives:
00000000000000000137ffffffffffedb6c92480001248137ec8125b6da5a480


You need  -mstackrealign to correct for the not aligned stack pointer that the
kernel gives.

Reply via email to