[PATCH] D23716: [ELF] Linkerscript: allow adding start/end symbols to arbitrary section
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 29 14:18:53 PDT 2016
ruiu added inline comments.
================
Comment at: ELF/LinkerScript.cpp:321
@@ +320,3 @@
+ OutputSectionBase<ELFT> *Sec) {
+ bool Start = true, LastSymType = Start;
+ for (std::unique_ptr<BaseCommand> &Base : Cmd->Commands) {
----------------
evgeny777 wrote:
> ruiu wrote:
> > It seems unnecessarily complicated to me. Why don't you do something like this?
> >
> > // Add start symbols.
> > for (int I = 0, E = Cmd->Commands.size(); I < E; ++I) {
> > if (!isa<SymbolAssignment>(Cmd->Commands[I]))
> > break;
> > ....
> > }
> >
> > // Add end symbols.
> > for (int I = Cmd->Commands.size() - 1; I >= 0; --I) {
> > if (!isa<SymbolAssignment>(Cmd->Commands[I]))
> > break;
> > ....
> > }
> >
> That's fine, but what about error diagnostics, you suggested to add last time?
Well, maybe something like this?
// Add start symbols.
int I = 0;
for (int E = Cmd->Commands.size(); I < E; ++I) {
if (!isa<SymbolAssignment>(Cmd->Commands[I]))
break;
....
}
// Add end symbols.
int J = Cmd->Commands.size() - 1;
for (; J >= 0; --J) {
if (!isa<SymbolAssignment>(Cmd->Commands[J]))
break;
....
}
// Warn on stray assignment expressions.
for (; I <= J; ++I)
if (auto *Foo = dyn_cast<SymbolAssignment>(Cmd->Commands[I])
....
https://reviews.llvm.org/D23716
More information about the llvm-commits
mailing list