This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Generalize finding output section by name.
AbandonedPublic

Authored by grimar on Oct 19 2017, 8:33 AM.

Details

Reviewers
ruiu
rafael
Summary

Change removes code duplication happened because
of 2 similar methods for searching output section by name what
hopefully makes code a bit cleaner.

Diff Detail

Event Timeline

grimar created this revision.Oct 19 2017, 8:33 AM
ruiu added inline comments.Oct 24 2017, 9:31 PM
ELF/LinkerScript.cpp
107

What does Location.empty() mean?

grimar added inline comments.Oct 25 2017, 4:35 AM
ELF/LinkerScript.cpp
107

It is the same as check in LinkerScript::createOutputSection.

When we parse scripts, sometimes we have forward references to sections,
like in following script (from addr-zero.s):

SECTIONS { foo = ADDR(.text) - ABSOLUTE(ADDR(.text)); };

In that case script parser calls getOrCreateOutputSection to declare output section early,
then Factory.addInputSec calls createOutputSection to define it and sets Location.

This function returns sections only if it was already defined (processed by factory).

ruiu added inline comments.Oct 25 2017, 3:31 PM
ELF/LinkerScript.cpp
107

That's too subtle. I couldn't understand it without your explanation, and you won't be able to understand that too if you come back to this code a few years later.

Also, why don't you want to return a forward reference?

grimar abandoned this revision.Dec 1 2017, 4:13 AM