Skip to content

section is ignored while exporting function via @export #23820

@vesim987

Description

@vesim987

Zig Version

0.14.0

Steps to Reproduce and Observed Behavior

@export(.{.section = "foo" } is ignored when used on functions
Simple repro:


pub fn _entry_point() callconv(.c) void {
    asm volatile (
        \\str r0, [r1]
    );
}

comptime {
    @export(&_entry_point, .{
        .name = "_entry_point",
        .section = ".hello",
    });
}
> zig build-obj -target thumb-freestanding -mcpu cortex_m0 main.zig -OReleaseFast
>  llvm-objdump -d ~/main.o 

main.o:	file format elf32-littlearm

Disassembly of section .text:

00000000 <_entry_point>:
       0: 6008         	str	r0, [r1]
       2: 4770         	bx	lr

Expected Behavior

@export should respect the .section field for function pointers or throw an error when both .section and function pointers are passed to it

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions