[lld] [ELF] PHDRS update while condition and phdrs.s unclose2.lds output (PR #100918)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 27 23:10:58 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld

@llvm/pr-subscribers-lld-elf

Author: Hongyu Chen (yugier)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/100918.diff


2 Files Affected:

- (modified) lld/ELF/ScriptParser.cpp (+6-6) 
- (modified) lld/test/ELF/linkerscript/phdrs.s (+1-1) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/100918


More information about the llvm-commits mailing list