summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Writer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r--lld/ELF/Writer.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index ac1d159219d..9f1346c090b 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -275,7 +275,7 @@ template <class ELFT> void Writer<ELFT>::run() {
: createPhdrs();
fixHeaders();
if (ScriptConfig->HasSections) {
- Script<ELFT>::X->assignAddresses();
+ Script<ELFT>::X->assignAddresses(Phdrs);
} else {
fixSectionAlignments();
assignAddresses();
@@ -1047,8 +1047,10 @@ std::vector<PhdrEntry<ELFT>> Writer<ELFT>::createPhdrs() {
// Add the first PT_LOAD segment for regular output sections.
uintX_t Flags = computeFlags<ELFT>(PF_R);
Phdr *Load = AddHdr(PT_LOAD, Flags);
- Load->add(Out<ELFT>::ElfHeader);
- Load->add(Out<ELFT>::ProgramHeaders);
+ if (!ScriptConfig->HasSections) {
+ Load->add(Out<ELFT>::ElfHeader);
+ Load->add(Out<ELFT>::ProgramHeaders);
+ }
Phdr TlsHdr(PT_TLS, PF_R);
Phdr RelRo(PT_GNU_RELRO, PF_R);
OpenPOWER on IntegriCloud