Originally posted by starshipeleven
View Post
Announcement
Collapse
No announcement yet.
Linux Kernel Finally Deprecating A.out Support
Collapse
X
-
Originally posted by Weasel View PostNot only does it not say exactly which symbol is from which library, but even worse you can load libraries for no reason (there was a thread some time ago where Fedora decided to strip away unused imports etc, a problem that should NOT exist in a sane format, like PE) if the symbol is satisfied from somewhere else.
- Likes 1
Comment
-
Originally posted by Jaxad0127 View PostHow does PE prevent unused imports? The format can't possibly not allow them, leaving the loader to either ignore them or block the executable, both of which should be possible with ELF.
Let's say you link to a library, but don't import and symbols from it in the end (perhaps because of some #ifdef or compiler optimization removing dead code, etc). It is trivial to see that there are unused libraries in PE because they will have no symbol table. It is impossible to know for an ELF after-the-fact (i.e. after linking) with global symbols (non-versioned) because you get a bunch of symbols and a bunch of libraries. So you need a linker option (what that thread was about) to do it during linking.
Sure you can scan your libraries and see whether they export those symbols, but what if the ELF file is not supposed to run on YOUR machine? Perhaps your libs don't export those symbols cause they're old or whatever.
This is the problem with ELF mentality, it assumes that "machine you compile on = environment you run on" which is just retarded.
For example, you also have to specify "-Wl,-unresolved-symbols=ignore-in-shared-libs" or else it assumes the above retardation, again.
Comment
-
-
Originally posted by F.Ultra View PostTake 2 seconds to contemplate if that is due to ELF or due to GCC/ld having a wrong default.
Comment
-
Originally posted by Weasel View PostLet's say you link to a library, but don't import and symbols from it in the end (perhaps because of some #ifdef or compiler optimization removing dead code, etc). It is trivial to see that there are unused libraries in PE because they will have no symbol table. It is impossible to know for an ELF after-the-fact (i.e. after linking) with global symbols (non-versioned) because you get a bunch of symbols and a bunch of libraries. So you need a linker option (what that thread was about) to do it during linking.
There is a thing that is called STT_FILE . When you static link with gcc and ld you nicely have STT_FILE insert into the symbol table so you know exactly what .o file did a function come from. Now you dynamic link gcc and ld results in no STT_FILE entries for the .so files used. You use the sun complier to make a dynamic linked binary the STT_FILE entries are in the dynamic link table so you know what .so file each function should be acquired from. This is not a ELF format bug this is a linker/loader bug to be correct GNU binutils and loader(glibc) bug.
There is a fun little fact that Weasel is not aware of. How did you historically do dynamic global symbols in PE. You used a dll name [GLOBAL] this is why you can put a library name in PE file without it having a symbol because that used to be used with global mode in the early Windows NT loader. So this bug that Weasel complains about with what he calling ELF also did exist in PE platforms at one point but the loader and compilers were modified no longer to support it. The format was not modified to fix this and ELF is in the same location.
I don't know how many more times I will have to tell Weasel this. Its not a problem with the ELF format. Its the problem with the compleirs/linkers/loaders used around the ELF format.
- Likes 2
Comment
-
Originally posted by oiaohm View PostThere is a thing that is called STT_FILE . When you static link with gcc and ld you nicely have STT_FILE insert into the symbol table so you know exactly what .o file did a function come from. Now you dynamic link gcc and ld results in no STT_FILE entries for the .so files used. You use the sun complier to make a dynamic linked binary the STT_FILE entries are in the dynamic link table so you know what .so file each function should be acquired from. This is not a ELF format bug this is a linker/loader bug to be correct GNU binutils and loader(glibc) bug.
You won't get it, so it's really a lost cause. You see, a loader CAN ignore a bunch of things, like a missing STT_FILE section. You can't ignore it in PE, though, because quite simply you CANNOT have a symbol table without a module associated with it. There's just "no way to encode it", not simply a matter of "loader refuses to load it". You cannot have it in the format, it's not up to the loader, like with ELF. This is what you simply won't get.
Originally posted by oiaohm View PostThere is a fun little fact that Weasel is not aware of. How did you historically do dynamic global symbols in PE. You used a dll name [GLOBAL] this is why you can put a library name in PE file without it having a symbol because that used to be used with global mode in the early Windows NT loader. So this bug that Weasel complains about with what he calling ELF also did exist in PE platforms at one point but the loader and compilers were modified no longer to support it. The format was not modified to fix this and ELF is in the same location.
Originally posted by oiaohm View PostI don't know how many more times I will have to tell Weasel this. Its not a problem with the ELF format. Its the problem with the compleirs/linkers/loaders used around the ELF format.
Comment
Comment