[PATCH] D24650: [ELF] - Linkerscript: PR30387 - cannot handle EXCLUDE_FILE in the middle of a input section description.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 17 12:18:26 PDT 2016


grimar added a comment.

In https://reviews.llvm.org/D24650#545515, @ruiu wrote:

> I just spent a few hours to clean up the linker script code and realized that it is getting hard to read because of lack of comments. There are bunch of functions and variables that are not obvious about what they are for, and the only way to understand it is reading code. The code may be easy to read if you already know what the code is doing, but our bar should be higher. I'll add more comments and refactor for simplification, but please write more comments in the first place to describe what you are trying to do for what purpose.


Sure, I will write more comments in future.


================
Comment at: lld/trunk/ELF/LinkerScript.cpp:992
@@ +991,3 @@
+// Example: *(.foo.1 EXCLUDE_FILE (*a.o) .foo.2 EXCLUDE_FILE (*b.o) .foo.3)
+void ScriptParser::readSectionExcludes(InputSectionDescription *Cmd) {
+  llvm::Regex ExcludeFileRe;
----------------
ruiu wrote:
> grimar wrote:
> > grimar wrote:
> > > ruiu wrote:
> > > > It's not clear to me what the grammar of this thing is.
> > > > 
> > > >   A B EXCLUDE_FILE(C) D E
> > > > 
> > > > Does the above pattern mean A, B, D except those matching C, and E? Or A, B, D except those matching C, E except those matching C?
> > > > 
> > > > What if the pattern is this?
> > > > 
> > > >   A B EXCLUDE_FILE(C) EXCLUDE_FILE(D) E
> > > > 
> > > Example from PR30387:
> > > 
> > > sec0 EXCLUDE_FILE (zed1.o) sec1  EXCLUDE_FILE (zed2.o) sec2 )
> > > 
> > > The semantics according to bfd are:
> > > Include sec1 from every file but zed1.o
> > > Include sec2 from every file but zed2.o
> > > Include sec0 from every file
> > > 
> > > So
> > > ```
> > > A B EXCLUDE_FILE(C) D E
> > > ```
> > > 
> > > Should be all A, B sections + all D, E excluding those in file C.
> > > 
> > > 
> > > Pattern of 
> > > ```
> > > A B EXCLUDE_FILE(C) EXCLUDE_FILE(D) E
> > > ```
> > > then should be all A, B + all E except those in file E.
> > Fix for last:
> > A B EXCLUDE_FILE(C) EXCLUDE_FILE(D) E
> > then should be all A, B + all E except those in **file D.**
> I think two consecutve EXCLUDE_FILEs are more like a syntax error than a valid grammar, no? Is there any reason you want to accept it?
Aim was to support example from PR30387 (so case from testcase). 
I thought you're asking how it works here (and believed bfd accepts the same),
but today found it is do not like consecutve EXCLUDE_FILEs. I can prepare a patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D24650





More information about the llvm-commits mailing list