Skip to content

Check elf magic before elf header size#27

Open
hannesweisbach wants to merge 3 commits into
Xilinx:masterfrom
hannesweisbach:patch-2
Open

Check elf magic before elf header size#27
hannesweisbach wants to merge 3 commits into
Xilinx:masterfrom
hannesweisbach:patch-2

Conversation

@hannesweisbach

@hannesweisbach hannesweisbach commented Jul 5, 2023

Copy link
Copy Markdown

Checking elf header size before elf magic may lead to presenting the user with a misleading error message in case the elf file header is corrupted or a non-elf file was entered into the bif file instead of an elf file (for example bl31.bin instead of bl31.elf.

Instead of receiving the misleading error message:
[ERROR] : ELF Parsing Error !!!
Wrong Header Size

The user is now presented with a more accurate error message:
[ERROR] : ELF Parsing Error !!!
ELF magic identification word wrong

Ramya Darapuneni and others added 3 commits November 3, 2022 15:33
This is to address pull request Xilinx#20
Checking elf header size before elf magic may lead to presenting the user with a misleading error message in case the elf file header is corrupted or a non-elf file was entered into the bif file instead of an elf file (for example bl31.bin instead of bl31.elf.

Instead of receiving the misleading error message:
[ERROR]  : ELF Parsing Error !!!
           Wrong Header Size

The user is now presented with a more accurate error message:
[ERROR]  : ELF Parsing Error !!!
          ELF magic identification word wrong
@kalvdans

kalvdans commented Jul 5, 2023

Copy link
Copy Markdown

Aren't both messages printed no matter the order of the checks?

@hannesweisbach

Copy link
Copy Markdown
Author

No, LOG_DEBUG calls Logger::Instance()->Error(), which in turn ends with throw BootGenException which is caught in main() and then the application exists.

@kalvdans

kalvdans commented Jul 5, 2023

Copy link
Copy Markdown

I see (you mean LOG_ERROR I presume). Then I agree that your suggested order is more natural.

@hannesweisbach

Copy link
Copy Markdown
Author

Yes, LOG_ERROR, of course 😅

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