[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH] automation: add linker symbol name script



On 2024-07-24 02:18, victorm.lira@xxxxxxx wrote:
From: Victor Lira <victorm.lira@xxxxxxx>


Hi,

Add a script that extracts the names of symbols in linker scripts.

Signed-off-by: Victor Lira <victorm.lira@xxxxxxx>
---
Note:
Not included are the "." location name or symbol names enclosed in quotes
since the files dont't use any.
---
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: roberto.bagnara@xxxxxxxxxxx
Cc: consulting@xxxxxxxxxxx
Cc: simone.ballarin@xxxxxxxxxxx
---
 automation/eclair_analysis/linker_symbols.sh | 41 +++++++++++++++++++
 automation/eclair_analysis/stuff.txt         | 42 ++++++++++++++++++++
 2 files changed, 83 insertions(+)
 create mode 100755 automation/eclair_analysis/linker_symbols.sh
 create mode 100644 automation/eclair_analysis/stuff.txt

diff --git a/automation/eclair_analysis/linker_symbols.sh b/automation/eclair_analysis/linker_symbols.sh
new file mode 100755
index 0000000000..c8c44e235f
--- /dev/null
+++ b/automation/eclair_analysis/linker_symbols.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+# Stop immediately if any executed command has exit status different from 0.
+set -e
+
+# Extract linker symbol names (except those starting with ".") from assignments.
+
+script_name=`basename "$0"`
+script_dir="$(
+  cd "$(dirname "$0")"
+  echo "${PWD}"
+)"
+src_dir="${script_dir}/../.."
+
+usage() {
+  echo "Usage: ${script_name} <ARM64|X86_64>"
+}
+
+if [ $# -ne 1 ]; then
+  usage
+  exit 1
+fi
+
+if [ "$1" == "X86_64" ]; then
+    filepaths=(
+        "${src_dir}/xen/arch/x86/xen.lds.S"
+    )
+elif [ "$1" == "ARM64" ]; then
+    filepaths=(
+        "${src_dir}/xen/arch/arm/xen.lds.S"
+    )
+else
+    usage
+    exit 1
+fi
+
+(
+    for file in "${filepaths[@]}"
+    do
+ sed -n "s/^\s*\([a-zA-Z_][a-zA-Z_0-9.\-]*\)\s*=.*;\s*$/\1/p" $filepaths
+    done
+)
diff --git a/automation/eclair_analysis/stuff.txt b/automation/eclair_analysis/stuff.txt
new file mode 100644
index 0000000000..efc33e6a59
--- /dev/null
+++ b/automation/eclair_analysis/stuff.txt

I wouldn't include the actual output in the patch. It' much better if I have a script that produces a list of symbols, and then use that to generate a configuration file right before the analysis.

@@ -0,0 +1,42 @@
+_start
+_idmap_start
+_idmap_end
+__proc_info_start
+__proc_info_end
+__note_gnu_build_id_start
+__note_gnu_build_id_end
+__ro_after_init_start
+__ro_after_init_end
+__start___ex_table
+__stop___ex_table
+__start___pre_ex_table
+__stop___pre_ex_table
+__start_schedulers_array
+__end_schedulers_array
+_splatform
+_eplatform
+_sdevice
+_edevice
+_asdevice
+_aedevice
+_steemediator
+_eteemediator
+__init_begin
+_sinittext
+_einittext
+__setup_start
+__setup_end
+__initcall_start
+__presmp_initcall_end
+__initcall_end
+__alt_instructions
+__alt_instructions_end
+__ctors_start
+__ctors_end
+__init_end_efi
+__init_end
+__bss_start
+__per_cpu_start
+__per_cpu_data_end
+__bss_end
+_end
--
2.37.6

--
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.