Index: lld/trunk/ELF/InputFiles.cpp =================================================================== --- lld/trunk/ELF/InputFiles.cpp +++ lld/trunk/ELF/InputFiles.cpp @@ -931,7 +931,7 @@ // characters in a filename are replaced with underscore. std::string S = "_binary_" + MB.getBufferIdentifier().str(); for (size_t I = 0; I < S.size(); ++I) - if (!isalnum(S[I])) + if (!elf::isAlnum(S[I])) S[I] = '_'; Symtab->addRegular(Saver.save(S + "_start"), STV_DEFAULT, STT_OBJECT, Index: lld/trunk/ELF/Strings.h =================================================================== --- lld/trunk/ELF/Strings.h +++ lld/trunk/ELF/Strings.h @@ -22,6 +22,7 @@ namespace elf { std::vector parseHex(StringRef S); +bool isAlnum(char C); bool isValidCIdentifier(StringRef S); // This is a lazy version of StringRef. String size is computed lazily Index: lld/trunk/ELF/Strings.cpp =================================================================== --- lld/trunk/ELF/Strings.cpp +++ lld/trunk/ELF/Strings.cpp @@ -58,7 +58,9 @@ return ('a' <= C && C <= 'z') || ('A' <= C && C <= 'Z') || C == '_'; } -static bool isAlnum(char C) { return isAlpha(C) || ('0' <= C && C <= '9'); } +// Returns true if C is a valid letter, digit or underscore as defined in the +// "C" locale. +bool elf::isAlnum(char C) { return isAlpha(C) || ('0' <= C && C <= '9'); } // Returns true if S is valid as a C language identifier. bool elf::isValidCIdentifier(StringRef S) { Index: lld/trunk/test/ELF/format-binary-non-ascii.s =================================================================== --- lld/trunk/test/ELF/format-binary-non-ascii.s +++ lld/trunk/test/ELF/format-binary-non-ascii.s @@ -0,0 +1,15 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t£.o + +# RUN: ld.lld -o %t.elf %t£.o --format=binary %t£.o +# RUN: llvm-readobj -symbols %t.elf | FileCheck %s + +# CHECK: Name: _binary_{{[a-zA-Z0-9_]+}}test_ELF_Output_format_binary_non_ascii_s_tmp___o_start +# CHECK: Name: _binary_{{[a-zA-Z0-9_]+}}test_ELF_Output_format_binary_non_ascii_s_tmp___o_end +# CHECK: Name: _binary_{{[a-zA-Z0-9_]+}}test_ELF_Output_format_binary_non_ascii_s_tmp___o_size + +.text +.align 4 +.globl _start +_start: + nop