I file /bin/ls
and get the output:
/bin/ls: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, stripped
And I found the reason is that my gentoo is compiling everything with -pie .
If I pass -nopie to gcc, I will get the right answer:
a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, not stripped
Also, I find something at building a .so that is also an executable. It uses -pie to make a DSO executable.
In gcc's man page, it describes in brief:
-pie
Produce a position independent executable on targets that support it.
So I'm wondering what -pie do exactly? How it makes my executable to be recognized as a shared object?
In the question, “What does it do?” do is the main verb and does is the auxiliary. As an auxiliary verb, does is followed by the base form of the main verb, which in this case is do. Your explanations fine. I admire Which is right? When do the children do their home work? When the children do their home work? (Is double ‘do’ necessary?
I always confuse when a sentence starts with “does”, the verb always follows with plural or single. Thank you. or does she like me. Does is an auxiliary verb that is used with the principal verb to form a verb phrase. It does not matter whether does comes at the beginning of the sentence or not.
The verb have is used in conjunction with the helping verb does. When the helping verb is used, the word have does not change no matter what the subject is. will it be like…then do you have any reason why we may bot talk ,, or does as reason is singular do in that case it should be does? The verb do agrees with the subject you.
What about the usage of Do and Does with I? Please quote some examples. The pronouns I, you, we, and they are always used with the word do. The pronouns he, she, and it are used with does. Examples: I do think it might rain tomorrow.
The distinction between "executable" and "shared object" is largely artificial. What the file
command is showing you is whether the ELF e_type
header is ET_EXEC
or ET_DYN
. This is a rather technical distinction and has to do with how the loader treats them. file
(via its magic file) should probably be taught to distinguish between "shared object" in the sense of "shared library" and "PIE executable" by looking for other characteristics like the presence of a PT_INTERP
program header (which libraries generally won't have) or perhaps an entry point address (although some libraries seem to have a meaningless one).
To address what -pie
does, it produces an executable that can be loaded at an arbitrary base address, rather than "normal" executables whose load addresses are fixed at ld
-time. These use the same type of position-independent code and load headers used in shared libraries, which are also loadable at arbitrary addresses (and which need to be loadable at arbitrary addresses since any fixed address might already be taken by the main executable or another library). PIE is generally considered a hardening mechanism (allowing address randomization to affect the address of code and data in the main program) but it can also have other uses like making binaries more appropriate for MMU-less systems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With