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

types are not respected with -no-builtin #21264

Open
4zv4l opened this issue Apr 12, 2024 · 1 comment
Open

types are not respected with -no-builtin #21264

4zv4l opened this issue Apr 12, 2024 · 1 comment
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@4zv4l
Copy link
Contributor

4zv4l commented Apr 12, 2024

Describe the bug

When compiling C project with -no-builtin, when using voidptr it does not translate to *void.
And when using variadic function, it creates a typedef array which does not exist

Reproduction Steps

helper.c

#include <linux/module.h>
#include <linux/proc_fs.h>

#define VV_LOCAL_SYMBOL
#define EMPTY_STRUCT_DECLARATION

MODULE_LICENSE("GPL");
MODULE_AUTHOR("4zv4l");

int kern__custom_init(void);
void kern__custom_exit(void);

module_init(kern__custom_init);
module_exit(kern__custom_exit);

proc.c.v

module kern

#include "helper.c"

fn C.pr_info(...charptr)
fn C.proc_create(charptr, int, int, &C.proc_ops)
fn C.remove_proc_entry(charptr, int)
struct C.proc_ops {
    proc_read fn(voidptr, &char, u32, &u64)
}

fn proc_read(file voidptr, buff &char, size u32, offset &u64) {

}

__global fops = C.proc_ops{proc_read: proc_read}
fn custom_init() int {
    C.pr_info(c"Hello module %s!\n", c"proc")
    C.proc_create(c"proc_proc", 0666, 0, &fops)
    return 0
}

fn custom_exit() {
    C.pr_info(c"Bye module !\n")
    C.remove_proc_entry(c"proc_proc", 0)
}

Makefile

obj-m += proc.o

all: proc.c
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
proc.c:
        vlang -no-builtin -no-preludes -enable-globals -gc none -o proc.c proc.c.v
clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

Expected Behavior

translating voidptr into void*
and avoid creating a potential useless array typedef (when removed, it works without issue)

Current Behavior

doenst translate voidptr to void* and create a array typedef which make a compile error

Possible Solution

No response

Additional Information/Context

image
  • line 48, the array definition
  • 76, 96 the voidptr

V version

V 0.4.5 2c646bf

Environment details (OS name and version, etc.)

Linux kali 6.3.0-kali1-amd64

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@4zv4l 4zv4l added the Bug This tag is applied to issues which reports bugs. label Apr 12, 2024
@4zv4l
Copy link
Contributor Author

4zv4l commented Apr 12, 2024

image

the global struct isn't initialized as it should as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

1 participant