[PATCH] D22740: Move Dot variable from LinkerScript to ScriptConfig.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 00:52:51 PDT 2016


grimar added a comment.

I am not sure that this change reflects the script context properly.
I mean that documentation says: ". actually refers to the byte offset from the start of the current containing object. Normally this is the SECTIONS statement, whose start address is 0, hence . can be used as an absolute address. If . is used inside a section description however, it refers to the byte offset from the start of that section, not an absolute address. "
(https://sourceware.org/binutils/docs-2.23/ld/Location-Counter.html)

Currently we are using "." only in assignAddresses, so we use absolete address. But we also will need to support the second case. In this implementation looks like we will need to reset the location counter for each OutputSectionCommand in createSections():

  for (const std::unique_ptr<BaseCommand> &Base : Opt.Commands) {
      auto *OutCmd = dyn_cast<OutputSectionCommand>(Base.get());
      if (!OutCmd)
        continue;
  
  Opt.Dot = 0;
  ....

I am not sure how nice that will look. As Dot becoming not the configuration state, but just temporarily variable, moved to configuration class.

I think we do not want to pass other such things like SIZEOF_HEADERS as arguments, they always have the same meaning. But dot itself looks better as argument for me.


https://reviews.llvm.org/D22740





More information about the llvm-commits mailing list