[PATCH] D97663: [llvm-objcopy] Fix crash for binary input files with non-ascii names
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 5 01:03:44 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG076698154ad7: [llvm-objcopy] Fix crash for binary input files with non-ascii names (authored by jhenderson).
Changed prior to commit:
https://reviews.llvm.org/D97663?vs=327044&id=328427#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97663/new/
https://reviews.llvm.org/D97663
Files:
llvm/test/tools/llvm-objcopy/ELF/binary-input.test
llvm/tools/llvm-objcopy/ELF/Object.cpp
Index: llvm/tools/llvm-objcopy/ELF/Object.cpp
===================================================================
--- llvm/tools/llvm-objcopy/ELF/Object.cpp
+++ llvm/tools/llvm-objcopy/ELF/Object.cpp
@@ -1290,8 +1290,9 @@
DataSection.Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE;
std::string SanitizedFilename = MemBuf->getBufferIdentifier().str();
- std::replace_if(std::begin(SanitizedFilename), std::end(SanitizedFilename),
- [](char C) { return !isalnum(C); }, '_');
+ std::replace_if(
+ std::begin(SanitizedFilename), std::end(SanitizedFilename),
+ [](char C) { return !isAlnum(C); }, '_');
Twine Prefix = Twine("_binary_") + SanitizedFilename;
SymTab->addSymbol(Prefix + "_start", STB_GLOBAL, STT_NOTYPE, &DataSection,
Index: llvm/test/tools/llvm-objcopy/ELF/binary-input.test
===================================================================
--- llvm/test/tools/llvm-objcopy/ELF/binary-input.test
+++ llvm/test/tools/llvm-objcopy/ELF/binary-input.test
@@ -118,3 +118,10 @@
# ALIGN: Name: .data
# ALIGN: AddressAlignment:
# ALIGN-SAME: 8{{$}}
+
+## Show that a filename with non-ASCII characters can be handled appropriately.
+## The exact encoding of the non-ASCII character will determine what characters
+## are used, so don't check for them specifically.
+# RUN: cp %t.x-txt %t€.x-txt
+# RUN: llvm-objcopy -I binary -O elf64-x86-64 %t€.x-txt %t3.o
+# RUN: llvm-readobj --sections --symbols %t3.o | FileCheck %s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97663.328427.patch
Type: text/x-patch
Size: 1498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210305/20300b8e/attachment.bin>
More information about the llvm-commits
mailing list