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

Does not Handle blockaddress constant #8

Open
rahulraghavendhra opened this issue Jun 15, 2015 · 1 comment
Open

Does not Handle blockaddress constant #8

rahulraghavendhra opened this issue Jun 15, 2015 · 1 comment

Comments

@rahulraghavendhra
Copy link

Hi,
I am interested in using this C-backend for my obfuscation project. The llvm-cbe breaks when I use Blockaddress constant. The below is the .ll file I used as the input to llvm-cbe.

; ModuleID = 'sample.c'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = private unnamed_addr constant [6 x i8] c"good\0A\00", align 1

; Function Attrs: nounwind uwtable
define i32 @main() #0 {
entry:
%retval = alloca i32, align 4
%addr = alloca i8_, align 8
store i32 0, i32_ %retval
store i8* blockaddress(@main, %FOO), i8** %addr, align 8
%0 = load i8** %addr, align 8
br label %indirectgoto

FOO: ; preds = %indirectgoto
%call = call i32 (i8_, ...)_ @printf(i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0))
ret i32 0

indirectgoto: ; preds = %entry
%indirect.goto.dest = phi i8* [ %0, %entry ]
indirectbr i8* %indirect.goto.dest, [label %FOO]
}

declare i32 @printf(i8*, ...) #1

attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.ident = !{!0}

!0 = metadata !{metadata !"clang version 3.5.0 (tags/RELEASE_350/final)"}

When I run llvm-cbe, the get the following error.

Unknown constant type: i8* blockaddress(@main, %FOO)
UNREACHABLE executed at CBackend.cpp:1205!
0 llvm-cbe 0x0000000001c7aff5 llvm::sys::PrintStackTrace(_IO_FILE*) + 38
1 llvm-cbe 0x0000000001c7b26d
2 llvm-cbe 0x0000000001c7abfd
3 libpthread.so.0 0x000000398240f710
4 libc.so.6 0x0000003981c32625 gsignal + 53
5 libc.so.6 0x0000003981c33e05 abort + 373
6 llvm-cbe 0x0000000001c6299b
7 llvm-cbe 0x0000000000ad394c
8 llvm-cbe 0x0000000000ad44de
9 llvm-cbe 0x0000000000ad458e
10 llvm-cbe 0x0000000000adfc75
11 llvm-cbe 0x0000000000ae17ff
12 llvm-cbe 0x0000000000ae0ee7
13 llvm-cbe 0x0000000000ad43c6
14 llvm-cbe 0x0000000000adb0d6
15 llvm-cbe 0x0000000000ad9ce1
16 llvm-cbe 0x0000000000acefc5
17 llvm-cbe 0x0000000001b71458 llvm::FPPassManager::runOnFunction(llvm::Function&) + 290
18 llvm-cbe 0x0000000001b715c8 llvm::FPPassManager::runOnModule(llvm::Module&) + 84
19 llvm-cbe 0x0000000001b7191c
20 llvm-cbe 0x0000000001b71fd0 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 250
21 llvm-cbe 0x0000000001b721f1 llvm::legacy::PassManager::run(llvm::Module&) + 39
22 llvm-cbe 0x0000000000aba25c
23 llvm-cbe 0x0000000000ab93f5 main + 252
24 libc.so.6 0x0000003981c1ed5d __libc_start_main + 253
25 llvm-cbe 0x0000000000ab8d09
Stack dump:
0. Program arguments: llvm-cbe sample.ll -debug

  1. Running pass 'Function Pass Manager' on module 'sample.ll'.
  2. Running pass 'C backend' on function '@main'
    Aborted (core dumped)

Is it that llvm-cbe doesn't support Blockaddress constants?

@rtc-draper
Copy link
Collaborator

Yes, it looks like it doesn't have anything to handle blockaddress constants. Duly noted to add that when we can...thanks for the bug report!

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

2 participants