[lld] [ELF] PHDRS update while condition and phdrs.s unclose2.lds output (PR #100918)
Hongyu Chen via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 27 23:10:26 PDT 2024
https://github.com/yugier created https://github.com/llvm/llvm-project/pull/100918
None
>From ae7e53bb951c96fdc9a37409d49495ee57758cad Mon Sep 17 00:00:00 2001
From: Hongyu Chen <hongyc4 at uci.edu>
Date: Sat, 27 Jul 2024 23:07:29 -0700
Subject: [PATCH] [ELF] PHDRS update while condition and phdrs.s unclose2.lds
output
---
lld/ELF/ScriptParser.cpp | 12 ++++++------
lld/test/ELF/linkerscript/phdrs.s | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index c033733877093..85143760f1540 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -524,17 +524,17 @@ void ScriptParser::readPhdrs() {
cmd.name = tok;
cmd.type = readPhdrType();
- while (!errorCount() && !consume(";")) {
- if (consume("FILEHDR"))
+ while (auto tok2 = till(";")) {
+ if (tok2 == "FILEHDR")
cmd.hasFilehdr = true;
- else if (consume("PHDRS"))
+ else if (tok2 == "PHDRS")
cmd.hasPhdrs = true;
- else if (consume("AT"))
+ else if (tok2 == "AT")
cmd.lmaExpr = readParenExpr();
- else if (consume("FLAGS"))
+ else if (tok2 == "FLAGS")
cmd.flags = readParenExpr()().getValue();
else
- setError("unexpected header attribute: " + next());
+ setError("unexpected header attribute: " + tok2);
}
script->phdrsCommands.push_back(cmd);
diff --git a/lld/test/ELF/linkerscript/phdrs.s b/lld/test/ELF/linkerscript/phdrs.s
index 997f7e39972d2..e43688bcb62f5 100644
--- a/lld/test/ELF/linkerscript/phdrs.s
+++ b/lld/test/ELF/linkerscript/phdrs.s
@@ -108,7 +108,7 @@ PHDRS { text PT_LOAD ;
PHDRS { text PT_LOAD
# RUN: not ld.lld -T unclosed2.lds a.o 2>&1 | FileCheck --check-prefix=UNCLOSED2 %s
-# UNCLOSED2: error: unclosed2.lds:1: unexpected header attribute:
+# UNCLOSED2: error: unclosed2.lds:1: unexpected EOF
#--- a.s
.global _start
More information about the llvm-commits
mailing list