Skip to content

generate invalid llir instructions #198

@x4evexnol

Description

@x4evexnol

source code helloworld.c

#include<stdio.h>

int main(){
printf("helloworld!");
return 0;
}

compile command gcc helloworld.c

execute command llvm-mctoll -d a.out -I /usr/include/stdio.h

generated a.out-dis.ll

execute command cat a.out-dis.ll

output

ModuleID = 'a.out'
source_filename = "a.out"

@rodata_18 = private unnamed_addr constant [16 x i8] c"\01\00\02\00helloworld!\00", align 4, !ROData_SecInfo !0

declare dso_local i32 @printf(ptr, ...)

define dso_local i32 @main() {
entry:
  %RSP_P.0 = alloca i64, align 1
  store i64 3735928559, ptr %RSP_P.0, align 8
  %RBP = ptrtoint ptr %RSP_P.0 to i64
  %EAX = call i32 (ptr, ...) @printf(ptr getelementptr inbounds ([16 x i8], ptr @rodata_18, i32 0, i32 4))
  ret i32 0
}

!0 = !{i64 8192}

execute command llvm-as a.out-dis.ll -o a.out-dis.bc

errors

error: '@rodata_18' defined with type '[16 x i8]*' but expected 'i8*'
  %EAX = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], i8* @rodata_18, i32 0, i32 4))

a.out-dis.ll:6:31: error: expected type
declare dso_local i32 @printf(ptr, ...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions