I don't understand the voting at all. It's asking why ldd
says what it does, which is a perfectly reasonable question regardless of the answer. The question has a very compact bug-free MCVE, and shows the build commands. Formatting is also fine.
The fact that it has an interesting (IMHO) answer related changes in the last few years (PIE executables, which most tutorials predate) is just icing on the cake, and why I bothered to write a long answer instead of a short one.
This is very nearly the platonic (socratic?) ideal of a good SO question: has a specific non-obvious answer with future value for other readers wondering the same thing. Answering questions like this (that have future value) are why I bother to wade through the sludge of so many boring other questions that are obvious.
The one thing it's maybe missing is info about what OS you ran these on, e.g. a distro name / version. That hardly justifies the downvotes without comments, especially after the question is answered. So IDK if that was what any of the downvoters were thinking. Comments are exactly for that kind of feedback of specific problems with posts.
I added the linux just now because the question (and answer) are likely specific to modern GNU/Linux distros that configure GCC with -pie
as the default. (Other OSes use different object-file formats.) If there was room for more tags, I'd also add back in the linker tag, and maybe glibc because that's where this version of ldd
is from.
The fact that it's Linux is already implied by the mov $60, %eax
/ syscall
; MacOS uses different call numbers, and a Windows system would make a.exe
not a.out
, not pass an arg in EDI, and other differences. Possibly there's a *BSD where this could work, but the other symptoms are perfectly explained by this being a GNU/Linux system with glibc and other GNU user-space..
But anyway, the only thing I can see at all wrong with the question is lack of info about what system this was run on. It didn't seem like a problem to me at all because I'm also using GNU/Linux, and didn't notice that was left implicit.
The question is nicely formatted with a good title so I was able to fully grok the question and start in on writing an answer in seconds after looking at it, not having to read every word like some questions where the key details are much harder to spot.
ldd
classifies them before.-pie
wasn't the default before 2015). Also, it's not about DLLs or libraries at all; it's a GNU/Linux question about executables and whatldd
says about them.