@@ -1314,7 +1314,7 @@ bool ElfView::Init()
13141314 continue ;
13151315 }
13161316
1317- if (m_objectFile)
1317+ if (m_objectFile && entry-> section != ELF_SHN_ABS )
13181318 {
13191319 if (entry->section >= m_elfSections.size ())
13201320 continue ;
@@ -1333,7 +1333,7 @@ bool ElfView::Init()
13331333 break ;
13341334 }
13351335 }
1336- } else
1336+ } else if (entry-> section != ELF_SHN_ABS )
13371337 entry->value += imageBaseAdjustment;
13381338
13391339 if (entry->section == ELF_SHN_UNDEF )
@@ -1598,14 +1598,12 @@ bool ElfView::Init()
15981598 }
15991599 }
16001600
1601- if (entry.type == ELF_STT_SECTION )
1601+ if (entry.section == ELF_SHN_ABS )
16021602 {
1603- // Section relative relocation
1604- if (auto section = GetSectionByName (entry.name ); section)
1605- {
1606- DefineRelocation (m_arch, relocInfo, section->GetStart (), relocInfo.address );
1607- continue ;
1608- }
1603+ // Absolute symbols are literal values, not addresses relative
1604+ // to the image or a section. They need not lie inside the view.
1605+ DefineRelocation (m_arch, relocInfo, entry.value , relocInfo.address );
1606+ continue ;
16091607 }
16101608 else if (!entry.section )
16111609 {
@@ -1653,24 +1651,22 @@ bool ElfView::Init()
16531651 }
16541652 else if (entry.section < m_elfSections.size ())
16551653 {
1656- // Linked images' st_value already contains a virtual address;
1657- // do not add the section address a second time. Keep ET_REL
1658- // lookup separate, since its st_value is section relative.
1659- uint64_t target = m_objectFile ? m_elfSections[entry.section ].address + entry.value :
1660- entry.value + imageBaseAdjustment;
1654+ // Only ET_REL st_value is section relative. Resolve both local
1655+ // and section symbols by their section index, not a potentially
1656+ // ambiguous name, and apply placement exactly once.
1657+ uint64_t target = entry.value + imageBaseAdjustment;
1658+ if (m_objectFile)
1659+ target += m_elfSections[entry.section ].address ;
16611660 auto symbol = GetSymbolByAddress (target);
16621661 if (symbol && !displayAliasAddresses.count (target))
16631662 {
16641663 DefineRelocation (m_arch, relocInfo, symbol, relocInfo.address );
16651664 continue ;
16661665 }
1667- if (!m_objectFile)
1668- {
1669- // A missing analysis symbol does not make a different
1670- // same-named GOT slot a definition of this ELF symbol.
1671- DefineRelocation (m_arch, relocInfo, target, relocInfo.address );
1672- continue ;
1673- }
1666+ // A missing analysis symbol does not make a different
1667+ // same-named local symbol or GOT slot a definition.
1668+ DefineRelocation (m_arch, relocInfo, target, relocInfo.address );
1669+ continue ;
16741670 }
16751671
16761672 // retrieve first symbol that is not a symbol relocation
0 commit comments