Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/eld/Diagnostics/DiagLayouts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,6 @@ DIAG(warning_zero_sized_fragment_for_non_zero_symbol, DiagnosticEngine::Warning,
DIAG(error_offset_not_assigned_for_output_section, DiagnosticEngine::Error,
"Requested offset for output section %0 has not yet been assigned")
DIAG(warn_empty_segment, DiagnosticEngine::Warning,
"Empty segment: '%0'")
"Empty segment: '%0'")
DIAG(note_section_address_not_converging, DiagnosticEngine::Note,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a warning instead?

"Section '%0' address did not converge after %1 layout passes")
4 changes: 3 additions & 1 deletion include/eld/Readers/ELFSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ class ELFSection : public ELFSectionBase {

uint64_t pAddr() const { return PAddr; }

bool hasLMA() const { return PAddr != InvalidAddr; }

void setOffsetAndAddr(uint64_t Off);

void setOffset(uint64_t Off) { Offset = Off; }
Expand Down Expand Up @@ -301,7 +303,7 @@ class ELFSection : public ELFSectionBase {
uint64_t Offset = ~uint64_t(0);
uint64_t Addr = InvalidAddr;
/// FIXME: only relevant for output sections.
uint64_t PAddr;
uint64_t PAddr = InvalidAddr;
LDSymbol *Symbol = nullptr;

/// FIXME: Only relevant for LTO. This should be moved out.
Expand Down
7 changes: 7 additions & 0 deletions include/eld/Target/GNULDBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "eld/Input/ELFDynObjectFile.h"
#endif
#include "eld/Object/ObjectBuilder.h"
#include "eld/Object/OutputSectionEntry.h"
#include "eld/Readers/CommonELFSection.h"
#include "eld/Readers/ELFExecObjParser.h"
#include "eld/Readers/ELFSection.h"
Expand Down Expand Up @@ -1046,6 +1047,10 @@ class GNULDBackend {
}
#endif

void setVMA(ELFSection &S, uint64_t vma, bool ignoreChangedSection);

void setLMA(ELFSection &S, uint64_t lma);

protected:
Module &m_Module;

Expand Down Expand Up @@ -1184,6 +1189,8 @@ class GNULDBackend {
GNUVerDefFragment *GNUVerDefFrag = nullptr;
std::unordered_map<const ResolveInfo *, uint16_t> OutputVersionIDs;
#endif
OutputSectionEntry * changedOutputSection = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout iterations only continue when section addresses change, but what about symbol-only forward references?

cat > 1.c << \!
int foo() {return 0;}
!

cat > cycle.t << \!
SECTIONS {
  . = 0x1000;
  .text : {*(.text*)}
  a = b + 4;
  b = a + 4;
}
!

cat > sym.t << \!
PHDRS {TEXT PT_LOAD;}
SECTIONS {
  . = 0x1000;
  .text : {*(.text*)} : TEXT
  a = b + 4;
  b = c + 4;
  c = 0x2000;
}
!

clang -c 1.c

ld.eld 1.o -T sym.t # a,b,c = 0x8,    0x2004, 0x2000
ld.lld 1.o -T sym.t # a,b,c = 0x2008, 0x2004, 0x2000

ld.lld 1.o -T cycle.t # error: assignment to symbol a does not converge
ld.eld 1.o -T cycle.t # a = 0x14; b=0x18

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout iterations only continue when section addresses change, but what about symbol-only forward references?

I plan to handle symbol address convergence in the next patch. The subsequent patches will add support for symbol address convergence, improved diagnostics related to layout iterations and convergence, and some heuristics to reduce the number of iterations wherever possible.

const int maxPreRelaxationPasses = 4;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like lld's max passes is 5. Is there any reason we picked a different number?


} // namespace eld
Expand Down
Loading
Loading