Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
scripts: Fix size mismatch of kexec_purgatory_size
Browse files Browse the repository at this point in the history
bin2c is used to create a valid C file out of a binary file where two
symbols will be globally defined: <name> and <name>_size. <name> is
passed as the first parameter of the host binary.

Building using goto-cc reported that the purgatory binary code (the only
current user of this utility) declares kexec_purgatory_size as 'size_t'
where bin2c generate <name>_size to be 'int' so in a 64-bit host where
sizeof(size_t) > sizeof(int) this type mismatch will always yield the
wrong value for big-endian architectures while for little-endian it will
be wrong if the object laid in memory directly after
kexec_purgatory_size contains non-zero value at the time of reading.

This commit changes <name>_size to be size_t instead.

Note:

Another way to fix the problem is to change the type of
kexec_purgatory_size to be 'int' as there's this check in code:
(kexec_purgatory_size <= 0)

Signed-off-by: Michael Tautschnig <[email protected]>
Cc: Vivek Goyal <[email protected]>
Acked-by: Dave Young <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
Tautschnig, Michael authored and Michal Marek committed Jul 22, 2016
1 parent ddea05f commit 21532b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/basic/bin2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ int main(int argc, char *argv[])
} while (ch != EOF);

if (argc > 1)
printf("\t;\n\nconst int %s_size = %d;\n", argv[1], total);
printf("\t;\n\n#include <linux/types.h>\n\nconst size_t %s_size = %d;\n",
argv[1], total);

return 0;
}

0 comments on commit 21532b9

Please sign in to comment.