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

elfloader: initialise stack allocated struct #198

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

Ivan-Velickovic
Copy link
Contributor

@Ivan-Velickovic Ivan-Velickovic commented Apr 9, 2024

Only results in a compilation error on newer GCC versions.

What confuses me though is this only happens for me in sel4bench, but not sel4test. I believe I'm using the same compiler in both projects, but se4lbench results in a unitialised warning that is treated as a compile error. sel4test does not even print the warning?

@axel-h
Copy link
Member

axel-h commented Apr 9, 2024

Maybe the compiler warning configuration is different in the projects?

@@ -61,7 +61,7 @@ static __attribute__((noinline)) int send_smc(uint8_t func, struct mce_regs *reg

static void tegra_mce_write_uncore_mca(mca_cmd_t cmd, uint64_t data, uint32_t *err)
{
struct mce_regs regs;
struct mce_regs regs = {0};
Copy link
Member

Choose a reason for hiding this comment

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

If gcc complain here, it should also complain about line 74 below in enable_serr(), where mca_cmd_t cmd has uninitialized fields, as it is also a stack variable that will start with content and we don't set all members. We should initialize this will all zeros also.

Copy link
Member

Choose a reason for hiding this comment

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

gcc might be smart enough to figure out that only the initialised fields are used from the one in line 74, esp if it inlines it. In fact, it appears enable_serr sets two fields of that struct/union that are never used. regs here on the other hand is passed to an asm block, so gcc is unlikely to know more.

Only results in a compilation error on newer GCC versions.

Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
@Ivan-Velickovic Ivan-Velickovic merged commit d3700e7 into seL4:master Aug 13, 2024
20 checks passed
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

Successfully merging this pull request may close these issues.

3 participants