Allow linker script to consider section attributes

The linker script now allows you to assign a section with the same
attributes as in the source.
To do this, I've removed a check from AssignSectionAddressAndBankByName
that would never be triggered, due to that condition being checked
before. Shouldn't this and IsSectionSameTypeBankAndAttrs be condensed
into a single function?
This commit is contained in:
mid-kid
2019-01-12 14:04:20 +01:00
parent 4b40d63dfd
commit c63af05427
12 changed files with 57 additions and 19 deletions

View File

@@ -321,8 +321,9 @@ struct sSection *GetSectionByName(const char *name)
return NULL;
}
int32_t IsSectionSameTypeBankAndFloating(const char *name,
enum eSectionType type, int32_t bank)
int32_t IsSectionSameTypeBankAndAttrs(const char *name,
enum eSectionType type, int32_t bank,
int32_t org, int32_t align)
{
const struct sSection *pSection;
@@ -340,8 +341,9 @@ int32_t IsSectionSameTypeBankAndFloating(const char *name,
* mismatch or not.
*/
/* Section must be floating in source */
if (pSection->nOrg != -1 || pSection->nAlign != 1)
/* Section must have the same attributes or float */
if ((pSection->nOrg != -1 && pSection->nOrg != org) ||
(pSection->nAlign != 1 && pSection->nAlign != align))
return 0;
/* It must have the same type in source and linkerscript */
@@ -374,15 +376,6 @@ uint32_t AssignSectionAddressAndBankByName(const char *name, uint32_t address,
/* Section has been found. */
/*
* A section can be left as floating in the code if the location
* is assigned in the linkerscript.
*/
if (pSection->nOrg != -1 || pSection->nAlign != 1) {
errx(1, "Section \"%s\" from linkerscript isn't floating.\n",
name);
}
/* The bank can be left as unassigned or be the same */
if (pSection->nBank != -1 && pSection->nBank != bank) {
errx(1, "Section \"%s\" from linkerscript has different bank number than in the source.\n",