[PATCH] D22589: [ELF] - Introduce output section description class for holding section command
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 03:45:33 PDT 2016
I don't think it would work because parsing linker scripts is not a
difficult part. That parser was not plugged into an actual logic to handle
complex linker script commands.
On Thu, Jul 21, 2016 at 2:57 AM, Sean Silva <chisophugis at gmail.com> wrote:
>
>
> On Wed, Jul 20, 2016 at 2:06 PM, Rui Ueyama via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> ruiu added inline comments.
>>
>> ================
>> Comment at: ELF/LinkerScript.h:49-59
>> @@ -48,8 +48,13 @@
>>
>> +struct OutputSectionDescription {
>> + std::vector<StringRef> Phdrs;
>> + std::vector<uint8_t> Filler;
>> +};
>> +
>> struct SectionsCommand {
>> SectionsCommandKind Kind;
>> std::vector<StringRef> Expr;
>> StringRef Name;
>> - std::vector<StringRef> Phdrs;
>> + OutputSectionDescription Section;
>> };
>>
>> ----------------
>> I think this is towards the right direction, but it doesn't still reflect
>> the structure of SECTIONS linker script command.
>>
>> As per the linker script manual (#1), SECTIONS command contains one of
>> the following sub-commands:
>>
>> - an ENTRY command
>> - an overlay description
>> - a symbol assignment
>> - an output section description
>>
>> Since we do not support the first two, I'll ignore them in this comment.
>> So focus on the last two. We can represent the two like this.
>>
>> enum SectionsCommandKind { AssignmentKind, DescriptionKind };
>>
>> struct SectionsCommand {
>> SectionsCommandKind Kind;
>> std::vector<StringRef> Expr; // For AssignmentKind
>> OutputSectionDescription Desc; // For DescriptionKind
>> };
>>
>> The above struct doesn't have `Name` field because SECTIONS doesn't have
>> a name.
>>
>> Name is instead in output section description as described in #2. To
>> reflect that grammar, you want to define a class like this.
>>
>> struct OutputSectionDescription {
>> StringRef Name;
>> std::vector<OutputSectionCommand> Commands;
>> std::vector<uint8_t> Filler;
>> };
>>
>> And then you want to define OutputSectionCommand to reflect
>> output-section-command as described in #2.
>>
>> So the point is to construct an AST whose structure logically matches
>> with the grammar.
>>
>
> Why don't we just bring back Rafael Auler's parser that was deleted? It
> was quite complete IIRC.
>
> -- Sean Silva
>
>
>>
>> #1 https://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS
>> #2 <https://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS%232>
>> https://sourceware.org/binutils/docs/ld/Output-Section-Description.html#Output-Section-Description
>>
>>
>> https://reviews.llvm.org/D22589
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160721/b9cf60be/attachment.html>
More information about the llvm-commits
mailing list