bug fix for grub-pe2elf
PATCH 1/1 bug fix for grub-pe2elf
Hi,
When symbol name is 8 or less, pe store it as short name, which is not necessary null-terminated. This patch take that into account and append a null character at the end.
util/grub-pe2elf.c +9 -2
@@ -344,10 +344,17 @@ write_symbol_table (FILE* fp, char *image, }else { +char short_name[9 ];char *name; - name = ((pe_symtab->long_name[0 ]) ? pe_symtab->short_name : - pe_strtab + pe_symtab->long_name[1 ]); +if (pe_symtab->long_name[0 ]) + { +strncpy (short_name, pe_symtab->short_name,8 ); + short_name[8 ] =0 ; + name = short_name; + } +else + name = pe_strtab + pe_symtab->long_name[1 ]; if ((strcmp (name, "_grub_mod_init")) && (strcmp (name, "_grub_mod_fini")) &&
Signature · 1 line
Bean
Quoted 4 lines · On Saturday 11 April 2009 18:29:00 Bean wrote:
Hi,
When symbol name is 8 or less, pe store it as short name, which is not necessary null-terminated.
Oh, I didn't know that. Where is it documented?
Regards,
Okuji
Quoted 7 lines · Yoshinori K. Okuji
Quoted 4 lines · On Saturday 11 April 2009 18:29:00 Bean wrote:
Hi,
When symbol name is 8 or less, pe store it as short name, which is not necessary null-terminated.
Oh, I didn't know that. Where is it documented?
Hi,
Recently, I found some wired symbol not found error in modules generated by mingw. After examining the binary image, it seems that PE would use short name even for symbol whose length is 8, therefore no null character at the end. grub-pe2elf assume the name is null-terminated, which could result in extra characters in the symbols.
Signature · 1 line
Bean
Quoted 9 lines · On Saturday 11 April 2009 21:07:51 Bean wrote:
Quoted 7 lines · Yoshinori K. Okuji
Quoted 4 lines · On Saturday 11 April 2009 18:29:00 Bean wrote:
Hi,
When symbol name is 8 or less, pe store it as short name, which is not necessary null-terminated.
Oh, I didn't know that. Where is it documented?
Quoted 8 lines
Hi,
Recently, I found some wired symbol not found error in modules generated by mingw. After examining the binary image, it seems that PE would use short name even for symbol whose length is 8, therefore no null character at the end. grub-pe2elf assume the name is null-terminated, which could result in extra characters in the symbols.
OK, so you've learned it from experience. :)
As I don't want to agree on Microsoft's annoying conditions, I don't read the official spec, but Wikipedia admits that your interpretation is right.
Regards,
Okuji
Hi,
ok, committed.
Quoted 32 lines · Yoshinori K. Okuji
Quoted 9 lines · On Saturday 11 April 2009 21:07:51 Bean wrote:
Quoted 7 lines · Yoshinori K. Okuji
Quoted 4 lines · On Saturday 11 April 2009 18:29:00 Bean wrote:
Hi,
When symbol name is 8 or less, pe store it as short name, which is not necessary null-terminated.
Oh, I didn't know that. Where is it documented?
Quoted 8 lines
Hi,
Recently, I found some wired symbol not found error in modules generated by mingw. After examining the binary image, it seems that PE would use short name even for symbol whose length is 8, therefore no null character at the end. grub-pe2elf assume the name is null-terminated, which could result in extra characters in the symbols.
OK, so you've learned it from experience. :)
As I don't want to agree on Microsoft's annoying conditions, I don't read the official spec, but Wikipedia admits that your interpretation is right.Regards,
Okuji_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 1 line
Bean