mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 21:08:36 +00:00
llvm backend: LLVMGetNamedGlobalAlias requires a null terminated string
This commit is contained in:
parent
a2eb91c422
commit
66e5920dc3
@ -454,12 +454,12 @@ pub const Object = struct {
|
||||
// Until then we iterate over existing aliases and make them point
|
||||
// to the correct decl, or otherwise add a new alias. Old aliases are leaked.
|
||||
for (exports) |exp| {
|
||||
if (self.llvm_module.getNamedGlobalAlias(exp.options.name.ptr, exp.options.name.len)) |alias| {
|
||||
const exp_name_z = try module.gpa.dupeZ(u8, exp.options.name);
|
||||
defer module.gpa.free(exp_name_z);
|
||||
|
||||
if (self.llvm_module.getNamedGlobalAlias(exp_name_z.ptr, exp_name_z.len)) |alias| {
|
||||
alias.setAliasee(llvm_fn);
|
||||
} else {
|
||||
const exp_name_z = try module.gpa.dupeZ(u8, exp.options.name);
|
||||
defer module.gpa.free(exp_name_z);
|
||||
|
||||
const alias = self.llvm_module.addAlias(llvm_fn.typeOf(), llvm_fn, exp_name_z);
|
||||
_ = alias;
|
||||
}
|
||||
|
||||
@ -193,7 +193,10 @@ pub const Module = opaque {
|
||||
pub const getNamedGlobalAlias = LLVMGetNamedGlobalAlias;
|
||||
extern fn LLVMGetNamedGlobalAlias(
|
||||
M: *const Module,
|
||||
Name: [*]const u8,
|
||||
/// Empirically, LLVM will call strlen() on `Name` and so it
|
||||
/// must be both null terminated and also have `NameLen` set
|
||||
/// to the size.
|
||||
Name: [*:0]const u8,
|
||||
NameLen: usize,
|
||||
) ?*const Value;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user