forked from OSchip/llvm-project
Fix PR23914.
r226830 moved the declaration of Buf to a nested scope, resulting in a dangling reference (in StringRef Name), and a use-after-free. llvm-svn: 240357
This commit is contained in:
parent
c05dd074e7
commit
9e0d41ab09
|
@ -842,12 +842,12 @@ void ELFObjectWriter::computeSymbolTable(
|
||||||
// seems that this information is not easily accessible from the
|
// seems that this information is not easily accessible from the
|
||||||
// ELFObjectWriter.
|
// ELFObjectWriter.
|
||||||
StringRef Name = Symbol.getName();
|
StringRef Name = Symbol.getName();
|
||||||
|
SmallString<32> Buf;
|
||||||
if (!Name.startswith("?") && !Name.startswith("@?") &&
|
if (!Name.startswith("?") && !Name.startswith("@?") &&
|
||||||
!Name.startswith("__imp_?") && !Name.startswith("__imp_@?")) {
|
!Name.startswith("__imp_?") && !Name.startswith("__imp_@?")) {
|
||||||
// This symbol isn't following the MSVC C++ name mangling convention. We
|
// This symbol isn't following the MSVC C++ name mangling convention. We
|
||||||
// can thus safely interpret the @@@ in symbol names as specifying symbol
|
// can thus safely interpret the @@@ in symbol names as specifying symbol
|
||||||
// versioning.
|
// versioning.
|
||||||
SmallString<32> Buf;
|
|
||||||
size_t Pos = Name.find("@@@");
|
size_t Pos = Name.find("@@@");
|
||||||
if (Pos != StringRef::npos) {
|
if (Pos != StringRef::npos) {
|
||||||
Buf += Name.substr(0, Pos);
|
Buf += Name.substr(0, Pos);
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
// Regression test for PR23914.
|
||||||
|
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -r -t | FileCheck %s
|
||||||
|
|
||||||
|
defined:
|
||||||
|
.symver defined, aaaaaaaaaaaaaaaaaa@@@AAAAAAAAAAAAA
|
||||||
|
|
||||||
|
// CHECK: Symbol {
|
||||||
|
// CHECK: Name: aaaaaaaaaaaaaaaaaa@@AAAAAAAAAAAAA
|
||||||
|
// CHECK-NEXT: Value: 0x0
|
||||||
|
// CHECK-NEXT: Size: 0
|
||||||
|
// CHECK-NEXT: Binding: Local
|
||||||
|
// CHECK-NEXT: Type: None
|
||||||
|
// CHECK-NEXT: Other: 0
|
||||||
|
// CHECK-NEXT: Section: .text
|
||||||
|
// CHECK-NEXT: }
|
||||||
|
|
Loading…
Reference in New Issue