Handle module_license on windows.
* util/grub-pe2elf.c (MODLICENSE_SECTION): New definition. All following sections shifted. (insert_string): Make argument const char * instead of char *. (write_section_data): Handle long section names. Handle module_license.
This commit is contained in:
parent
d4de6b01e8
commit
2217a1430e
2 changed files with 39 additions and 15 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Handle module_license on windows.
|
||||||
|
|
||||||
|
* util/grub-pe2elf.c (MODLICENSE_SECTION): New definition. All following
|
||||||
|
sections shifted.
|
||||||
|
(insert_string): Make argument const char * instead of char *.
|
||||||
|
(write_section_data): Handle long section names.
|
||||||
|
Handle module_license.
|
||||||
|
|
||||||
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
2011-05-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/commands/menuentry.c (grub_cmd_menuentry): Correctly
|
* grub-core/commands/menuentry.c (grub_cmd_menuentry): Correctly
|
||||||
|
|
|
@ -79,11 +79,12 @@ Report bugs to <%s>.\n", program_name, PACKAGE_BUGREPORT);
|
||||||
#define BSS_SECTION 4
|
#define BSS_SECTION 4
|
||||||
#define MODNAME_SECTION 5
|
#define MODNAME_SECTION 5
|
||||||
#define MODDEPS_SECTION 6
|
#define MODDEPS_SECTION 6
|
||||||
#define SYMTAB_SECTION 7
|
#define MODLICENSE_SECTION 7
|
||||||
#define STRTAB_SECTION 8
|
#define SYMTAB_SECTION 8
|
||||||
|
#define STRTAB_SECTION 9
|
||||||
|
|
||||||
#define REL_SECTION 9
|
#define REL_SECTION 10
|
||||||
#define MAX_SECTIONS 12
|
#define MAX_SECTIONS 16
|
||||||
|
|
||||||
#define STRTAB_BLOCK 256
|
#define STRTAB_BLOCK 256
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ int num_sections;
|
||||||
grub_uint32_t offset;
|
grub_uint32_t offset;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
insert_string (char *name)
|
insert_string (const char *name)
|
||||||
{
|
{
|
||||||
int len, result;
|
int len, result;
|
||||||
|
|
||||||
|
@ -124,6 +125,8 @@ write_section_data (FILE* fp, char *image,
|
||||||
{
|
{
|
||||||
int *section_map;
|
int *section_map;
|
||||||
int i;
|
int i;
|
||||||
|
char *pe_strtab = (image + pe_chdr->symtab_offset
|
||||||
|
+ pe_chdr->num_symbols * sizeof (struct grub_pe32_symbol));
|
||||||
|
|
||||||
section_map = xmalloc ((pe_chdr->num_sections + 1) * sizeof (int));
|
section_map = xmalloc ((pe_chdr->num_sections + 1) * sizeof (int));
|
||||||
section_map[0] = 0;
|
section_map[0] = 0;
|
||||||
|
@ -131,31 +134,42 @@ write_section_data (FILE* fp, char *image,
|
||||||
for (i = 0; i < pe_chdr->num_sections; i++, pe_shdr++)
|
for (i = 0; i < pe_chdr->num_sections; i++, pe_shdr++)
|
||||||
{
|
{
|
||||||
grub_uint32_t idx;
|
grub_uint32_t idx;
|
||||||
|
const char *name = pe_shdr->name;
|
||||||
|
|
||||||
if (! strcmp (pe_shdr->name, ".text"))
|
if (name[0] == '/' && isdigit (name[1]))
|
||||||
|
{
|
||||||
|
char t[sizeof (pe_shdr->name) + 1];
|
||||||
|
memcpy (t, name, sizeof (pe_shdr->name));
|
||||||
|
t[sizeof (pe_shdr->name)] = 0;
|
||||||
|
name = pe_strtab + atoi (t + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! strcmp (name, ".text"))
|
||||||
{
|
{
|
||||||
idx = TEXT_SECTION;
|
idx = TEXT_SECTION;
|
||||||
shdr[idx].sh_flags = SHF_ALLOC | SHF_EXECINSTR;
|
shdr[idx].sh_flags = SHF_ALLOC | SHF_EXECINSTR;
|
||||||
}
|
}
|
||||||
else if (! strcmp (pe_shdr->name, ".rdata"))
|
else if (! strcmp (name, ".rdata"))
|
||||||
{
|
{
|
||||||
idx = RDATA_SECTION;
|
idx = RDATA_SECTION;
|
||||||
shdr[idx].sh_flags = SHF_ALLOC;
|
shdr[idx].sh_flags = SHF_ALLOC;
|
||||||
}
|
}
|
||||||
else if (! strcmp (pe_shdr->name, ".data"))
|
else if (! strcmp (name, ".data"))
|
||||||
{
|
{
|
||||||
idx = DATA_SECTION;
|
idx = DATA_SECTION;
|
||||||
shdr[idx].sh_flags = SHF_ALLOC | SHF_WRITE;
|
shdr[idx].sh_flags = SHF_ALLOC | SHF_WRITE;
|
||||||
}
|
}
|
||||||
else if (! strcmp (pe_shdr->name, ".bss"))
|
else if (! strcmp (name, ".bss"))
|
||||||
{
|
{
|
||||||
idx = BSS_SECTION;
|
idx = BSS_SECTION;
|
||||||
shdr[idx].sh_flags = SHF_ALLOC | SHF_WRITE;
|
shdr[idx].sh_flags = SHF_ALLOC | SHF_WRITE;
|
||||||
}
|
}
|
||||||
else if (! strcmp (pe_shdr->name, ".modname"))
|
else if (! strcmp (name, ".modname"))
|
||||||
idx = MODNAME_SECTION;
|
idx = MODNAME_SECTION;
|
||||||
else if (! strcmp (pe_shdr->name, ".moddeps"))
|
else if (! strcmp (name, ".moddeps"))
|
||||||
idx = MODDEPS_SECTION;
|
idx = MODDEPS_SECTION;
|
||||||
|
else if (strcmp (name, ".module_license") == 0)
|
||||||
|
idx = MODLICENSE_SECTION;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
section_map[i + 1] = -1;
|
section_map[i + 1] = -1;
|
||||||
|
@ -181,14 +195,14 @@ write_section_data (FILE* fp, char *image,
|
||||||
|
|
||||||
if (pe_shdr->relocations_offset)
|
if (pe_shdr->relocations_offset)
|
||||||
{
|
{
|
||||||
char name[5 + strlen (pe_shdr->name)];
|
char relname[5 + strlen (name)];
|
||||||
|
|
||||||
if (num_sections >= MAX_SECTIONS)
|
if (num_sections >= MAX_SECTIONS)
|
||||||
grub_util_error ("too many sections");
|
grub_util_error ("too many sections");
|
||||||
|
|
||||||
sprintf (name, ".rel%s", pe_shdr->name);
|
sprintf (relname, ".rel%s", name);
|
||||||
|
|
||||||
shdr[num_sections].sh_name = insert_string (name);
|
shdr[num_sections].sh_name = insert_string (relname);
|
||||||
shdr[num_sections].sh_link = i;
|
shdr[num_sections].sh_link = i;
|
||||||
shdr[num_sections].sh_info = idx;
|
shdr[num_sections].sh_info = idx;
|
||||||
|
|
||||||
|
@ -197,7 +211,7 @@ write_section_data (FILE* fp, char *image,
|
||||||
num_sections++;
|
num_sections++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
shdr[idx].sh_name = insert_string (pe_shdr->name);
|
shdr[idx].sh_name = insert_string (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return section_map;
|
return section_map;
|
||||||
|
|
Loading…
Reference in a new issue