zilch-lang/nstar

Concatenating sections

Closed this issue · 0 comments

With the new target-dependent compilation feature introduced in #37, code examples like:

target "x86-any" {
    section rodata {
        arch; *char
            [ 'x', '8', '6' ]
    }
}

section rodata {
    format1: *char
        [ '%' 'd' ' '+' ' ' '%' 'd' ' ' '=' ' ' '%' 'd' '\n' '\0' ]
}

are made available.
In this specific case, post-processing would yield:

section rodata {
    arch: *char
        [ 'x' '8' '6' ]
    format1: *char
        [ '%' 'd' ' '+' ' ' '%' 'd' ' ' '=' ' ' '%' 'd' '\n' '\0' ]
}

(The first item in the source code is the first item in the result code)


While the example above isn't a problem, this specific example is:

target "x86-any" {
    section rodata {
        x: u64
            0
    }
}

section rodata {
    x: char
        'c'
}

because it would yield

section rodata {
    x: u64
        0
}

and not

section rodata {
    x: char
        'c'
}

nor

section rodata {
    x: u64
        0
    x: char
        'c'
}

This specific use-case, while not really being erroneous, should be reported as a warning to the user, maybe something like overlapping <label> in section <section-name> at lines N and M.