This is PR28868. More details on a bug page.
Patch fixes the issue by ignoring such "zero" sections.
Details
- Reviewers
ruiu • rafael - Commits
- rG683a35d0660f: [ELF] - Fix for: error "invalid section index: xxx" when linking FreeBSD kernel.
rLLD278550: [ELF] - Fix for: error "invalid section index: xxx" when linking FreeBSD kernel.
rL278550: [ELF] - Fix for: error "invalid section index: xxx" when linking FreeBSD kernel.
Diff Detail
- Repository
- rL LLVM
Event Timeline
hpt27xx_lib.o file used in bug is prebuilt and has about 1.1mb size. I do not know way to reduce it or to produce
smaller sample. Should I use it or we can just rely on the fact that the change works for linking it in BSD world ?
No. Not quite. We don't have a FreeBSD buildbot that does CI and even if we had it this code can break at any time and it will require somebody (likely me or Ed Maste) to ask for a revert. Please take the time to reduce this test case.
As Davide pointed out, it needs a testcase. This is a subtle change, and I'm not sure if this is a bug of LLD.
I think it is definely not an issue of lld. But since that file was precompiled in the wild and ld works fine here, I think we also should
support this case, right ?
I`ll try to reduce it and prepare testcase, though I have no idea now how to do that since as I mentioned it is precompiled.
You can probably localize the issue is and create a llvm-mc testcase which reproduces it.
If you can't you can check in a small binary (modified with hexedit or something similar) or use yaml2obj to craft an object of this kind.
Now that I understand what kind of file you are trying to handle. This seems pretty weird. How does this happen? Do you know who created that file?
ELF/InputFiles.cpp | ||
---|---|---|
345 ↗ | (On Diff #67308) | This is not a good place to fix it. Set InputSectionBase<ELFT>::Discarded to REL/RELA sections instead. |
I am not certain about hpt27xx_lib.o, but a similar case in FreeBSD was due to the outdated GNU binutils 2.17.50 that we have, and has now been fixed by https://svnweb.freebsd.org/base?view=revision&revision=303158
Ed, do you happen to know the ld version number that produced wrong object files? I think we are fine with this change, but I'd like to add that information as the comment.
davide@freefall:~ % ld --version GNU ld 2.17.50 [FreeBSD] 2007-07-03 Copyright 2007 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License. This program has absolutely no warranty.
Actually, I think you might want the version of as(1). It's the same.
% as --version GNU assembler 2.17.50 [FreeBSD] 2007-07-03 Copyright 2007 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License. This program has absolutely no warranty. This assembler was configured for a target of `x86_64-unknown-freebsd'.
ELF/InputFiles.cpp | ||
---|---|---|
345 ↗ | (On Diff #67308) | Ok, BTW, it also touches .shstrtab, .symtab, .strtab sections in originall issue. |
ELF/InputFiles.cpp | ||
---|---|---|
279–280 ↗ | (On Diff #67487) | Because hpt27xx_lib.o which initially was the reason to fix all of that Testcase also has them:
|
ELF/Writer.cpp | ||
100–101 ↗ | (On Diff #67487) | Because since these sections are mo more nullptr, but discarded, the code below is executed |
By the way, I have to notice that initial version of the patch has only 2 lines of code changed.
May be we can go with it ?
OK, please revert to the original patch. But please keep the comment. Comments to describe why you needed these changes are as important as the code that does them.