this post was submitted on 28 May 2025
731 points (96.3% liked)

Programmer Humor

24369 readers
800 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

Also, do y'all call main() in the if block or do you just put the code you want to run in the if block?

you are viewing a single comment's thread
view the rest of the comments
[โ€“] barsoap@lemm.ee 1 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

~~Your ld.so contains:~~

~~Entry point address: 0x1d780~~

EDIT: ...with which I meant, modulo brainfart: My libc.so.6 contains a proper entry address, while other libraries are pointing at 0x0 and coredump when executed. libc.so is a linker script, presumably because GNU compulsively overcomplicates everything.

...I guess that's enough for the kernel. It might be a linux-only thing, maybe even unintended and well linux doesn't break userspace.

Speaking of, I was playing it a bit fast and loose: _start is merely the default symbol name for the entry label, I'm sure nasm and/or ld have ways to set it to something different.

[โ€“] JATtho@lemmy.world 1 points 3 weeks ago* (last edited 3 weeks ago)

Btw, ld.so is a symlink to ld-linux-x86-64.so.2 at least on my system. It is an statically linked executable. The ld.so is, in simpler words, an interpreter for the ELF format and you can run it:

ld.so --help

Entry point address: 0x1d780

Which seems to be contained in the only executable ~~section~~ segment of ld.so

LOAD 0x0000000000001000 0x0000000000001000 0x0000000000001000
     0x0000000000028bb5 0x0000000000028bb5  R E    0x1000

Edit: My understanding of this quite shallow; the above is a segment that in this case contains the entirety of the .text section.