[lld] r320817 - Handle a VersymIndex of 0 as an error.
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 21 05:16:01 PST 2017
Hi Rafael,
Starting from this commit I get the following error in attempt to
build MIPS executable:
[[
error: corrupt input file: version definition index 0 for symbol
_gp_disp is out of bounds
>>> defined in ..../code-2017.10-mti/lib/gcc/mips-mti-linux-gnu/6.3.0/../../../../mips-mti-linux-gnu/lib/mipsel-r2-hard/lib/libgcc_s.so.1
]]
The "_gp_disp" symbol defined in the "libgcc_s.so.1" as "SECTION
GLOBAL DEFAULT ABS". The "libgcc_s.so.1" is a part of CodeScape
toolchain and linked using GNU tools.
Do you think that libgcc_s.so.1 has broken version info or global
section symbol is a corner case and zero VersymIndex is a correct
value?
For the reference here is the link to the "libgcc_s.so.1":
https://drive.google.com/open?id=1xp3eU34G4N6oSY5HeVKBHNLXwzXJK5O6
Regards,
Simon
On Fri, Dec 15, 2017 at 5:52 PM, Rafael Espindola via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: rafael
> Date: Fri Dec 15 06:52:40 2017
> New Revision: 320817
>
> URL: http://llvm.org/viewvc/llvm-project?rev=320817&view=rev
> Log:
> Handle a VersymIndex of 0 as an error.
>
> I noticed that the continue this patch deletes was not tested. Trying
> to add a test I realized that we never put a VER_NDX_LOCAL symbol in
> the dynamic symbol table. There doesn't seem to be any reason for a
> linker to use VER_NDX_LOCAL for a defined shared symbol.
>
> Modified:
> lld/trunk/ELF/InputFiles.cpp
> lld/trunk/test/ELF/corrupted-version-reference.s
>
> Modified: lld/trunk/ELF/InputFiles.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=320817&r1=320816&r2=320817&view=diff
> ==============================================================================
> --- lld/trunk/ELF/InputFiles.cpp (original)
> +++ lld/trunk/ELF/InputFiles.cpp Fri Dec 15 06:52:40 2017
> @@ -793,7 +793,7 @@ template <class ELFT> void SharedFile<EL
> // Add symbols to the symbol table.
> Elf_Sym_Range Syms = this->getGlobalELFSyms();
> for (const Elf_Sym &Sym : Syms) {
> - unsigned VersymIndex = 0;
> + unsigned VersymIndex = VER_NDX_GLOBAL;
> if (Versym) {
> VersymIndex = Versym->vs_index;
> ++Versym;
> @@ -813,12 +813,9 @@ template <class ELFT> void SharedFile<EL
> continue;
> }
>
> - // Ignore local symbols.
> - if (Versym && VersymIndex == VER_NDX_LOCAL)
> - continue;
> const Elf_Verdef *Ver = nullptr;
> if (VersymIndex != VER_NDX_GLOBAL) {
> - if (VersymIndex >= Verdefs.size()) {
> + if (VersymIndex >= Verdefs.size() || VersymIndex == VER_NDX_LOCAL) {
> error("corrupt input file: version definition index " +
> Twine(VersymIndex) + " for symbol " + Name +
> " is out of bounds\n>>> defined in " + toString(this));
More information about the llvm-commits
mailing list