Jeff-Lewis / address-sanitizer

Automatically exported from code.google.com/p/address-sanitizer
0 stars 0 forks source link

Programs with __attribute__((annotate)) fail to link under AddressSanitizer #279

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
$ cat t.cc
#include <unistd.h>

class A {
 public:
  __attribute__((annotate("aaa")))
  int GetValue();
 private:
  int value;
};

int A::GetValue() {
  return value;
}

int main() {
  A a;
  return 0;
} 

$ clang++ t.cc -o t -std=c++11 -o t -fsanitize=address
/tmp/t-89eeb2.o:(.data+0x0): undefined reference to `.str'
/tmp/t-89eeb2.o:(.data+0x30): undefined reference to `.str1'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Original issue reported on code.google.com by ramosian.glider@gmail.com on 20 Mar 2014 at 8:20

GoogleCodeExporter commented 9 years ago
Reduced testcase:

$ cat t.cc 
__attribute__((annotate("aaa")))
int getvalue() { return 1; }

int main() {
  return getvalue();
} 

Original comment by ramosian.glider@gmail.com on 20 Mar 2014 at 8:25

GoogleCodeExporter commented 9 years ago
$ build/Release+Asserts/bin/clang++ t.cc  -std=c++11 -S -emit-llvm 
$ cat t.ll
...
@.str = private unnamed_addr constant [4 x i8] c"aaa\00", section 
"llvm.metadata"
@.str1 = private unnamed_addr constant [5 x i8] c"t.cc\00", section 
"llvm.metadata"
@llvm.global.annotations = appending global [1 x { i8*, i8*, i8*, i32 }] [{ 
i8*, i8*, i8*, i32 } { i8* bitcast (i32 ()* @_Z8getvaluev to i8*), i8* 
getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr 
inbounds ([5 x i8]* @.str1, i32 0, i32 0), i32 2 }], section "llvm.metadata"
...

Original comment by ramosian.glider@gmail.com on 20 Mar 2014 at 8:26

GoogleCodeExporter commented 9 years ago
Fixed in LLVM r204331.

Original comment by ramosian.glider@gmail.com on 20 Mar 2014 at 10:55

GoogleCodeExporter commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Original comment by ramosian.glider@gmail.com on 30 Jul 2015 at 9:14