Xilinx / bootgen

bootgen source code
Other
34 stars 42 forks source link

Check elf magic before elf header size #27

Open hannesweisbach opened 1 year ago

hannesweisbach commented 1 year ago

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 commented 1 year ago

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

hannesweisbach commented 1 year ago

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 commented 1 year ago

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

hannesweisbach commented 1 year ago

Yes, LOG_ERROR, of course 😅