[llvm] [JITLink] Use `rsplit` on `-sectcreate` argument in llvm-jitlink (PR #115511)

via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 08:35:32 PST 2024


https://github.com/dgg5503 created https://github.com/llvm/llvm-project/pull/115511

This accounts for cases where the file path may contain an `@` symbol. In such cases, the split occurs too early causing argument parsing to fail.

>From 7cae18d3eabf0de7e359026c3887b2911aff2906 Mon Sep 17 00:00:00 2001
From: Douglas Gliner <Douglas.Gliner at sony.com>
Date: Thu, 7 Nov 2024 17:51:55 -0800
Subject: [PATCH] Use `rsplit` on `-sectcreate` argument in llvm-jitlink

This accounts for cases where the file path may contain an `@` symbol. In
such cases, the split occurs too early causing argument parsing to fail.
---
 .../Generic/Inputs/{ => sect at create}/sectcreate-data.txt        | 0
 llvm/test/ExecutionEngine/JITLink/Generic/sectcreate.test       | 2 +-
 llvm/tools/llvm-jitlink/llvm-jitlink.cpp                        | 2 +-
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename llvm/test/ExecutionEngine/JITLink/Generic/Inputs/{ => sect at create}/sectcreate-data.txt (100%)

diff --git a/llvm/test/ExecutionEngine/JITLink/Generic/Inputs/sectcreate-data.txt b/llvm/test/ExecutionEngine/JITLink/Generic/Inputs/sect at create/sectcreate-data.txt
similarity index 100%
rename from llvm/test/ExecutionEngine/JITLink/Generic/Inputs/sectcreate-data.txt
rename to llvm/test/ExecutionEngine/JITLink/Generic/Inputs/sect at create/sectcreate-data.txt
diff --git a/llvm/test/ExecutionEngine/JITLink/Generic/sectcreate.test b/llvm/test/ExecutionEngine/JITLink/Generic/sectcreate.test
index c09513a7d3707c..08b6372dcf2c73 100644
--- a/llvm/test/ExecutionEngine/JITLink/Generic/sectcreate.test
+++ b/llvm/test/ExecutionEngine/JITLink/Generic/sectcreate.test
@@ -1,6 +1,6 @@
 # RUN: llc -filetype=obj -o %t.o %S/Inputs/main-ret-0.ll
 # RUN: llvm-jitlink -noexec \
-# RUN:   -sectcreate __data,%S/Inputs/sectcreate-data.txt at foo=0 \
+# RUN:   -sectcreate __data,%S/Inputs/sect at create/sectcreate-data.txt at foo=0 \
 # RUN:   %t.o
 #
 # Use -sectcreate to create a section from a data file.
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index cc144cda18e1a3..261daae5e67f94 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -1740,7 +1740,7 @@ static Error addSectCreates(Session &S,
 
     StringRef SCArg(*SCItr);
 
-    auto [SectAndFileName, ExtraSymbolsString] = SCArg.split('@');
+    auto [SectAndFileName, ExtraSymbolsString] = SCArg.rsplit('@');
     auto [SectName, FileName] = SectAndFileName.rsplit(',');
     if (SectName.empty())
       return make_error<StringError>("In -sectcreate=" + SCArg +



More information about the llvm-commits mailing list