Skip to content
Merged
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
6 changes: 6 additions & 0 deletions lib/Target/CreateProgramHeaders.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ bool GNULDBackend::createProgramHdrs() {
noLoadSections.clear();
resetNewSectionsAddedToLayout();
enable_RELRO = true;

{
eld::RegisterTimer T("Evaluate Script Assignments", "Establish Layout",
m_Module.getConfig().options().printTimingStats());
evaluateScriptAssignments(/*evaluateAsserts=*/false);
}
};

reset_state();
Expand Down
6 changes: 6 additions & 0 deletions lib/Target/CreateScriptProgramHeaders.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ bool GNULDBackend::createScriptProgramHdrs() {
m_ImageStartVMA = vma;
// Set initial dot symbol value.
dotSymbol->setValue(vma);

{
eld::RegisterTimer T("Evaluate Script Assignments", "Establish Layout",
m_Module.getConfig().options().printTimingStats());
evaluateScriptAssignments(/*evaluateAsserts=*/false);
}
};

reset_state();
Expand Down
7 changes: 0 additions & 7 deletions lib/Target/GNULDBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3060,13 +3060,6 @@ bool GNULDBackend::layout() {
// Clear the section table so that real sections can be inserted properly.
m_Module.clearOutputSections();

// Evaluate defsym assignments.
{
eld::RegisterTimer T("Evaluate Script Assignments", "Establish Layout",
m_Module.getConfig().options().printTimingStats());
evaluateScriptAssignments(false);
}

// If partial link, we only set offsets, no addresses.
if (isPartialLink) {
if (!setOutputSectionOffset()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#---IncorrectAssignmentInLayoutReiteration.test------ LinkerScript ----------------#
#BEGIN_COMMENT
# Verify OUTSIDE_SECTIONS assignments are re-evaluated whenever layout resets.
#END_COMMENT
#START_TEST
RUN: %clang %clangopts -o %t1.1.o %p/Inputs/1.c -c -ffunction-sections
RUN: %link %linkopts -o %t1.1.out %t1.1.o -T %p/Inputs/script.t -Map %t1.1.map.txt
RUN: %readelf -s %t1.1.out | %filecheck %s
#END_TEST

CHECK-DAG: {{0*100}} 0 NOTYPE GLOBAL DEFAULT ABS v
CHECK-DAG: {{0*100}} 0 NOTYPE GLOBAL DEFAULT ABS u
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int foo() { return 1; }

int val = 3;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
u = 0x100;
SECTIONS {
v = u;
.text : { *(.text*) }
u = 0x300;
.data : { *(.data*) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#---IncorrectAssignmentInLayoutReiterationWithPHDRS.test-- LinkerScript -------------#
#BEGIN_COMMENT
# Verify OUTSIDE_SECTIONS assignments are re-evaluated when layout resets,
# even when PHDRS is used.
#END_COMMENT
#START_TEST
RUN: %clang %clangopts -o %t1.1.o %p/Inputs/1.c -c -ffunction-sections
RUN: %link %linkopts -o %t1.1.out %t1.1.o -T %p/Inputs/script.t -Map %t1.1.map.txt
RUN: %readelf -s %t1.1.out | %filecheck %s
#END_TEST

CHECK-DAG: {{0*100}} 0 NOTYPE GLOBAL DEFAULT ABS v
CHECK-DAG: {{0*100}} 0 NOTYPE GLOBAL DEFAULT ABS u
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int foo() { return 1; }

int val = 3;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
u = 0x100;
PHDRS
{
text PT_LOAD FLAGS(5);
data PT_LOAD FLAGS(6);
}
SECTIONS {
v = u;
.text : { *(.text*) } :text
u = 0x300;
.data : { *(.data*) } :data
}
Loading