New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It appears you skipped over the padding between vendor length and number of formats... #6
Comments
Good catch, the docs explicitly mention the padding:
I'll try to make a fix in the next days. It boils down to padding to the next multiple of 4. libX11 uses this macro: #define ROUNDUP(nbytes, pad) (((nbytes) + ((pad)-1)) & ~(long)((pad)-1)) and gcc optimizes it to: add eax, 3
and eax, -4 |
I am curious if gdb works for you. Since I'm not getting line number information into my output ELF64, it just runs to the end of the program when I try to single step through the code and the only place I can set breakpoints is at labels. I guess I could just put a bunch of labels into the code around the part I want to look at. This is what I did to see the vendor string in your "x11_send_handshake" function: . . . ; Set the root_visual_id globally. ; DEBUG -- output vendor string mov eax, r10d add rsp, 1<<15 -- Todd |
Gdb (version 13.2-1) does work for me out of the box including with line numbers:
Alternatively, breaking on the function name (i.e.: label) should also work but be a bit more cumbersome. If all fails, gdb can also add a breakpoint at a certain address so one could disassemble like this (assuming no Position Independent Code):
and note at which addresses the interesting code locations are e.g.
Perhaps make sure you compile with |
Fixed in fdead46 |
Just fyi, I tried it on an Arch Linux based distro and gdb was working. Looks like Ubuntu is doing something odd.
-- Todd
On Monday, June 26, 2023 at 06:17:40 PM GMT+8, Philippe Gaultier ***@***.***> wrote:
Gdb does work for me out of the box including with line numbers:
(gdb) b x11.nasm:111
Breakpoint 1 at 0x401096: file x11.nasm, line 111.
(gdb) r
Starting program: /home/pg/my-code/nasm-work/x11.exe
Breakpoint 1, x11_send_handshake () at x11.nasm:111
111 syscall
(gdb) n
113 cmp rax, 12*8 ; Check that all bytes were written.
(gdb) p ***@***.***
Attempt to dereference a generic pointer.
(gdb) p * ***@***.***
$1 = "l\000\v\000\000\000\000\000\000\000\000"
(gdb)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
I could be wrong, but looking at the X documentation there appears to be padding between the vendor length and the number of formats (reference: your x11_send_handshake function). Since the vendor string was likely "The X.Org Foundation" which is 5*4 bytes long, no padding was required for this case.
I was trying to use gdb to look at this, but it complains about no line number information in the executable. I compiled with '-g' so I expected all the required debug info to be there. Do you know what might be the problem? I'm using the following: NASM version 2.15.05 / GNU ld (GNU Binutils for Ubuntu) 2.38 / GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1 in case it is a version specific problem.
I ended up doing a system call to write the vendor string to STDOUT.
-- Todd
The text was updated successfully, but these errors were encountered: