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

[makerom] bss section included in .cia and allocated twice on program load #20

Closed
aliaspider opened this issue Jan 16, 2016 · 6 comments

Comments

@aliaspider
Copy link

currently the .bss section seems to be duplicated in the data section, which will cause the issues mentioned in the title.

you can easily test this by creating a 10MB static array (make sure you also reference it in the code because --gc-sections will remove it otherwise). this will greatly increase the size of the generated .cia and will also reduce the available memory at runtime by 20MB, instead of just 10.

@jakcron
Copy link
Collaborator

jakcron commented Jan 16, 2016

Hmm, when I make 10MB static arrays

static char ARRAY[10*1024*1024] = {0};
printf("arr %s", ARRAY);

The CXI is ~10MB. (without compression ofc)

I suggest checking your linker script, because makerom just takes ELF segments as described in the ELF program headers.

Can you upload one of these offending ELFs, also telling what the BSS size for that ELF should be?

@aliaspider
Copy link
Author

the exefs shouldn't include the bss section in the first place right ? the fact that the CXI gets that big is the problem.
older makerom versions worked correctly, I stumbled upon this problem after the devkitarm update, so I guess a commit around that time caused it.

the bss section in the elf is reported correctly, I tested using the standard linker script in devkitarm just to make sure.

I can upload an elf if you want, but you can reproduce the problem already.

the fact that older makerom doesn't work well with current devkitarm makes this harder to test, ill see if I can find/create an elf file with a huge bss section that works with both old and current makerom so you can see the difference.

@jakcron
Copy link
Collaborator

jakcron commented Jan 16, 2016

Oh, I see. Well the fix should be easy. I'm just not sure EXEFS has to include the BSS section.

But since available memory is reduced by twice the size, it appears, that it doesn't have to include it.

@jakcron
Copy link
Collaborator

jakcron commented Jan 16, 2016

You are right, checking the old code ripped from the SDK makerom, the segment processing code has this in the loop that calculates the segment size:

if (IsBss(&seg[i]->sections[seg[i]->sectionNum - 1]))
    memorySize -= seg[i]->sections[seg[i]->sectionNum - 1].size;

@aliaspider
Copy link
Author

you found a solution already, cool :D

@jakcron
Copy link
Collaborator

jakcron commented Jan 16, 2016

Fixed: 8ac78ca

@jakcron jakcron closed this as completed Jan 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants