Question

I want to get source code of .o file. I think ld command reads the source code (Assembly or original). Because:

For example, when I want to convert .o files to executable file, I see this warning:

ld: warning: cannot find entry symbol _start

or this:

in function `abc'

or this:

undefined reference to `xyz'
Was it helpful?

Solution

.o files don't have source code on them, only object code.

ld doesn't read the source code from the .o files, only the object code.

The reason ld knows there's an undefined reference to `xyz' is because the object file has an undefined reference to xyz in its object code.

The reason ld knows there's no _start is because the object file has no object code for _start in it.

Licensed under: CC-BY-SA with attribution
scroll top