Skip to content

Linker alignment in 16bit mode #7

@anchorz

Description

@anchorz

The symbols in .bss segment are ALWAYS 4 byte aligned. That is probably a mistake. Only 'LONG' should be aligned to 4 bytes (in 16 or 32 bit code that does not matter, by that way we will keep the memory layout independent from compiler options.)

tempoffset = symptr->value;
symptr->value = ld_roundup(comsz[seg = symptr->flags & SEGM_MASK],tempoffset,bin_off_t);
comsz[seg] = symptr->value+tempoffset;

The program

int i1=5;
long l=1;
long bss_l;
char c3='3';
int i2=0x7fff;
char c2='3';

int bss_i1;
char bss_c3;
int bss_i2;
char bss_c2;

int main()
{
}
ld86 -i -d -T 0x100 -D 0x0000 -H 0xf000 -M
produces the following linker output
test _i1 3 00000000 R
test _l 3 00000002 R
test _c3 3 00000006 R
test _i2 3 00000008 R
test _c2 3 0000000a R
test _bss_i1 3 0000000c R C
test _bss_i2 3 00000010 R C
test _bss_c2 3 00000014 R C
test _bss_c3 3 00000018 R C
test _bss_l 3 0000001c R C
test _main 0 00000100 R

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions