Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ramosian-glider opened this issue Aug 31, 2015 · 4 comments

Comments

@ramosian-glider
Copy link
Member

Originally reported on Google Code with ID 279

$ 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)

Reported by ramosian.glider on 2014-03-20 08:20:08

@ramosian-glider
Copy link
Member Author

Reduced testcase:

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

int main() {
  return getvalue();
} 

Reported by ramosian.glider on 2014-03-20 08:25:08

@ramosian-glider
Copy link
Member Author

$ 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"
...

Reported by ramosian.glider on 2014-03-20 08:26:08

@ramosian-glider
Copy link
Member Author

Fixed in LLVM r204331.

Reported by ramosian.glider on 2014-03-20 10:55:36

  • Status changed: Fixed

@ramosian-glider
Copy link
Member Author

Adding Project:AddressSanitizer as part of GitHub migration.

Reported by ramosian.glider on 2015-07-30 09:14:07

  • Labels added: ProjectAddressSanitizer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant