Skip to content

rimage: manifest: Improve handling of empty segments - #8531

Merged
kv2019i merged 2 commits into
thesofproject:mainfrom
softwarecki:rimage-fix-rodata
Dec 4, 2023
Merged

rimage: manifest: Improve handling of empty segments#8531
kv2019i merged 2 commits into
thesofproject:mainfrom
softwarecki:rimage-fix-rodata

Conversation

@softwarecki

Copy link
Copy Markdown
Collaborator

Fixed output segment size calculation. If a given output segment type did not contain any input section (was empty), its size was incorrectly calculated as 1 and then rounded to the page size (4096). This resulted in an unnecessary segment in a output file.

Improved handling of empty RODATA segment. If the RODATA segment does not contain any data, its type is now marked as empty. Cleared the readonly flag of RODATA segment because this segment also contains .data sections.

If a given output segment type did not contain any input section
(was empty), its size was incorrectly calculated as 1 and then rounded to
the page size (4096). This resulted in an unnecessary segment in a output
file.
Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
@lyakh

Copy link
Copy Markdown
Collaborator

Cleared the readonly flag of RODATA segment because this segment also contains .data sections.

We only have one section in the manifest, that contains both .data and .rodata, right? This is in fact not good, can this be fixed?

lyakh
lyakh previously requested changes Nov 28, 2023
Comment threadtools/rimage/src/module.c
Comment threadtools/rimage/src/manifest.c
If the RODATA segment does not contain any data, its type is marked as
empty. Cleared the readonly flag because this segment also contains .data
sections.
Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
@softwarecki

Copy link
Copy Markdown
CollaboratorAuthor

@lyakh

We only have one section in the manifest, that contains both .data and .rodata, right? This is in fact not good, can this be fixed?

I'm afraid there is no good solution for this. The manifest only supports max three segments. Currently we use them like this:

  1. .text
  2. .rodata.data
  3. .bss
    I think this is due to the assumption that loadable modules don't have a .data section, only .text, .rodata and .bss.

@lyakh

Copy link
Copy Markdown
Collaborator

@lyakh

We only have one section in the manifest, that contains both .data and .rodata, right? This is in fact not good, can this be fixed?

I'm afraid there is no good solution for this. The manifest only supports max three segments. Currently we use them like this:

1. `.text`
2. `.rodata` `.data`
3. .`bss`
I think this is due to the assumption that loadable modules don't have a `.data` section, only `.text`, `.rodata` and `.bss`.

I don't really understand this assumption - modules are allowed to have .rodata, i.e. const objects, e.g. operations, and they're allowed to have .bss, i.e. writable initialised to 0 data, why aren't they then supposed to have writable but initialised to non-0 values data?

@lgirdwood

Copy link
Copy Markdown
Member

@lyakh

We only have one section in the manifest, that contains both .data and .rodata, right? This is in fact not good, can this be fixed?

I'm afraid there is no good solution for this. The manifest only supports max three segments. Currently we use them like this:

1. `.text`
2. `.rodata` `.data`
3. .`bss`
I think this is due to the assumption that loadable modules don't have a `.data` section, only `.text`, `.rodata` and `.bss`.

I don't really understand this assumption - modules are allowed to have .rodata, i.e. const objects, e.g. operations, and they're allowed to have .bss, i.e. writable initialised to 0 data, why aren't they then supposed to have writable but initialised to non-0 values data?

I think we have been merging .rodata and .data in the same manifest section to date using the linker and rimage.

@keqiaozhang

Copy link
Copy Markdown
Collaborator

SOFCI TEST

Comment threadtools/rimage/src/manifest.c

@kv2019ikv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok. @lyakh please take a look at the clarifications.

@lyakh
lyakh dismissed their stale reviewDecember 1, 2023 08:57

questions remain, but none of them are critical

@kv2019i
kv2019i merged commit e36b77c into thesofproject:mainDec 4, 2023
@softwarecki
softwarecki deleted the rimage-fix-rodata branch March 4, 2024 15:07
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rimageIssues related to rimage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@softwarecki@lyakh@lgirdwood@keqiaozhang@kv2019i@pjdobrowolski@serhiy-katsyuba-intel