Commit 1106761
elf: when relocating do not lookup STB_LOCAL symbols by name
As the issue #1065 describes, some linkers (like gold) in certain scenarios generate
ELF objects that end up with symbols with local binding (STB_LOCAL) that need
to be relocated. The known concrete scenarios involve symbols of type STT_SECTION
and STT_TLS which fail to get relocated by OSv linker as it attempts to look
them up by name and they are not present in the relevant string lookup tables
or worse point to the empty name in the string table at index 0.
To address it we follow what Musl does which is simply looking
such symbols by index in the current ELF object instead of by name.
This patch also adds extra unit test that fails without this patch
to prove that the fix is correct.
Fixes #1065
Signed-off-by: Waldemar Kozaczuk <jwkozaczuk@gmail.com>
Message-Id: <20191223170751.7166-1-jwkozaczuk@gmail.com>1 parent c9640a3 commit 1106761
2 files changed
+17
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
645 | 649 | | |
646 | 650 | | |
647 | 651 | | |
648 | | - | |
649 | 652 | | |
650 | 653 | | |
651 | 654 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
165 | 177 | | |
166 | 178 | | |
167 | 179 | | |
| |||
0 commit comments