mirror of
https://github.com/intel/llvm.git
synced 2026-01-19 17:45:07 +08:00
[ELF] - Do not remove empty sections that use symbols in expressions.
This is PR36515.
Currenly if we have a script like .debug_info 0 : { *(.debug_info) },
we would not remove this section and keep it in the output.
That does not work, because it is common case for
debug sections to have a zero address expression.
Patch changes behavior so that we remove only sections
that do not use symbols in its expressions.
Differential revision: https://reviews.llvm.org/D43863
llvm-svn: 326430
This commit is contained in:
@@ -778,11 +778,10 @@ static bool isDiscardable(OutputSection &Sec) {
|
||||
if (!Sec.Phdrs.empty())
|
||||
return false;
|
||||
|
||||
// We do not want to remove sections that have custom address or align
|
||||
// expressions set even if them are empty. We keep them because we
|
||||
// want to be sure that any expressions can be evaluated and report
|
||||
// an error otherwise.
|
||||
if (Sec.AddrExpr || Sec.AlignExpr || Sec.LMAExpr)
|
||||
// We do not want to remove sections that reference symbols in address and
|
||||
// other expressions. We add script symbols as undefined, and want to ensure
|
||||
// all of them are defined in the output, hence have to keep them.
|
||||
if (Sec.ExpressionsUseSymbols)
|
||||
return false;
|
||||
|
||||
for (BaseCommand *Base : Sec.SectionCommands)
|
||||
|
||||
Reference in New Issue
Block a user