lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20141231164306.GA1872@dhcppc1>
Date:	Wed, 31 Dec 2014 17:43:06 +0100
From:	Sylvain BERTRAND <sylvain.bertrand@...il.com>
To:	x86@...nel.org
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH v2 1/3] x86: tools: shell-ify calc_run_size perl-ism


Add the shell script.

Signed-off-by: Sylvain BERTRAND <sylvain.bertrand@...il.com>
---
--- arch/x86/tools/calc_run_size.sh
+++ arch/x86/tools/calc_run_size.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# Calculate the amount of space needed to run the kernel, including room for
+# the .bss and .brk sections.
+#
+# Usage:
+# objdump -h a.out | sh calc_run_size.sh
+
+set -e
+
+file_offset=0
+mem_size=0
+
+while read Idx Name Size_hex VMA_hex LMA_hex File_off_hex Algn
+do
+	if [ "$Name" = ".bss" -o "$Name" = ".brk" ]; then
+		Size=$((0x$Size_hex))
+		File_off=$((0x$File_off_hex))
+
+		mem_size=$(($mem_size + $Size))
+
+		if [ $file_offset -eq 0 ]; then
+			file_offset=$File_off
+		elif [ $file_offset -ne $File_off ]; then
+			# BFD linker shows the same file offset in ELF.
+			# Gold linker shows them as consecutive.
+			if [ $(($file_offset + $mem_size)) -eq $(($File_off + $Size)) ]; then
+				continue
+			fi
+			
+			printf "file_offset: 0x%x\n" $file_offset >&2
+			printf "mem_size: 0x%x\n" $mem_size >&2
+			printf "offset: 0x%x\n" $File_off >&2
+			printf "size: 0x%x\n" $Size >&2
+
+			echo ".bss and .brk are non-contiguous" >&2
+			exit 1
+		fi
+	fi
+done
+
+if [ $file_offset -eq 0 ]; then
+	echo "Never found .bss or .brk file offset" >&2
+	exit 1
+fi
+printf "%d\n" $(($mem_size + $file_offset))
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ