diff --git a/llvm/test/tools/llvm-objcopy/ELF/binary-input.test b/llvm/test/tools/llvm-objcopy/ELF/binary-input.test --- a/llvm/test/tools/llvm-objcopy/ELF/binary-input.test +++ b/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 diff --git a/llvm/tools/llvm-objcopy/ELF/Object.cpp b/llvm/tools/llvm-objcopy/ELF/Object.cpp --- a/llvm/tools/llvm-objcopy/ELF/Object.cpp +++ b/llvm/tools/llvm-objcopy/ELF/Object.cpp @@ -1291,7 +1291,7 @@ std::string SanitizedFilename = MemBuf->getBufferIdentifier().str(); std::replace_if(std::begin(SanitizedFilename), std::end(SanitizedFilename), - [](char C) { return !isalnum(C); }, '_'); + [](char C) { return !isAlnum(C); }, '_'); Twine Prefix = Twine("_binary_") + SanitizedFilename; SymTab->addSymbol(Prefix + "_start", STB_GLOBAL, STT_NOTYPE, &DataSection,