Re: [PATCH] x86, kaslr: Prevent .bss from overlaping initrd

From: Fengguang Wu
Date: Thu Oct 30 2014 - 11:06:42 EST


Hi Junjie,

I got one error with this script:

awk: arch/x86/tools/calc_reserved.awk: line 23: function strtonum never defined

Have you tried both gawk/mawk?

Thanks,
Fengguang

> diff --git a/arch/x86/tools/calc_reserved.awk b/arch/x86/tools/calc_reserved.awk
> new file mode 100644
> index 000000000000..2ca69682338a
> --- /dev/null
> +++ b/arch/x86/tools/calc_reserved.awk
> @@ -0,0 +1,21 @@
> +#!/bin/awk -f
> +#
> +# Calculate the amount of space that we have to reserve for .bss and .brk
> +# sections
> +#
> +# Usage:
> +# objdump -h a.out | awk -f calc_reserved.awk
> +
> +BEGIN {
> + sections = "^.bss$|^.brk$"
> + size = 0;
> +}
> +
> +/^ *[0-9]+ [a-z._]+ *[0-9a-f]+/ {
> + if (match($2, sections))
> + size += strtonum("0x" $3);
> +}
> +
> +END {
> + printf("%d\n", size);
> +}
> --
> 1.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/