This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-06-25 06:00:05 +00:00
parent 9f0f6dc054
commit e658498578
5 changed files with 50 additions and 6 deletions

View File

@@ -25348,7 +25348,7 @@ For this reason, we use it in particular often in this README to reduce the need
==== run-toolchain ==== run-toolchain
While you could just manually find/learn the path to toolchain tools, e.g. in LKMC b15a0e455d691afa49f3b813ad9b09394dfb02b7 they are While you could just manually find/learn the path to toolchain tools, e.g. in LKMC b15a0e455d691afa49f3b813ad9b09394dfb02b7 they are:
.... ....
./out/buildroot/build/default/aarch64/host/bin/aarch64-buildroot-linux-gnu-gcc userland/c/hello.c ./out/buildroot/build/default/aarch64/host/bin/aarch64-buildroot-linux-gnu-gcc userland/c/hello.c
@@ -25374,6 +25374,12 @@ which outputs as of LKMC b15a0e455d691afa49f3b813ad9b09394dfb02b7:
/path/to/linux-kernel-module-cheat/out/buildroot/build/default/aarch64/host/usr/bin/aarch64-buildroot-linux-gnu /path/to/linux-kernel-module-cheat/out/buildroot/build/default/aarch64/host/usr/bin/aarch64-buildroot-linux-gnu
.... ....
Since disassembly of a single function with GDB is such a common use case https://stackoverflow.com/questions/22769246/how-to-disassemble-one-single-function-using-objdump[], we have a shortcut for it:
....
./disas --arch aarch64 --userland userland/c/hello.c main
....
=== Rebuild Buildroot while running === Rebuild Buildroot while running
It is not possible to rebuild the root filesystem while running QEMU because QEMU holds the file qcow2 file: It is not possible to rebuild the root filesystem while running QEMU because QEMU holds the file qcow2 file:

View File

@@ -231,7 +231,7 @@ class CliFunction:
def cli_noexit(self, cli_args=None): def cli_noexit(self, cli_args=None):
''' '''
Call the function from the CLI. Parse command line arguments Call the function from the CLI. Parse command line arguments
to get all arguments. to get all arguments. Does not exit the program after running this function.
:return: the return of main :return: the return of main
''' '''
@@ -435,6 +435,8 @@ amazing function!
# Positional # Positional
out = one_cli_function(pos_mandatory=1, pos_optional=2, args_star=['3', '4']) out = one_cli_function(pos_mandatory=1, pos_optional=2, args_star=['3', '4'])
# TODO: make actual positional arguments work.
# out = one_cli_function(1, 2, '3', '4')
assert out['pos_mandatory'] == 1 assert out['pos_mandatory'] == 1
assert out['pos_optional'] == 2 assert out['pos_optional'] == 2
assert out['args_star'] == ['3', '4'] assert out['args_star'] == ['3', '4']

View File

@@ -1345,6 +1345,8 @@ lunch aosp_{}-eng
These are arguments that might be used by more than one script, These are arguments that might be used by more than one script,
and are all defined in this class instead of in the derived class and are all defined in this class instead of in the derived class
of the script. of the script.
This can be used to forward common arguments to a call of another CLI function.
''' '''
return { return {
key:self.env[key] for key in self._common_args if key:self.env[key] for key in self._common_args if

38
disas Executable file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python3
import os
import lkmc.import_path
import common
from shell_helpers import LF
class Main(common.LkmcCliFunction):
def __init__(self):
super().__init__(
defaults = {
'show_time': False,
},
description='''\
Disassemble one function of the given executable.
https://cirosantilli.com/linux-kernel-module-cheat#run-toolchain
''',
)
self.add_argument('function', help='Which function to disassemble.')
def timed_main(self):
lkmc.import_path.import_path_main('run-toolchain')(
tool='gdb',
extra_args=[
'-nh',
'-batch',
'-ex',
'disas/rs {}'.format(self.env['function']),
self.env['image'],
],
quiet=True,
**self.get_common_args()
)
if __name__ == '__main__':
Main().cli()

View File

@@ -34,10 +34,6 @@ Suitable for programmatic consumption by other shell programs.
) )
def timed_main(self): def timed_main(self):
if self.env['baremetal']:
image = self.env['vmlinux']
else:
image = self.env['image']
tool = self.get_toolchain_tool(self.env['tool']) tool = self.get_toolchain_tool(self.env['tool'])
if self.env['print_tool']: if self.env['print_tool']:
print(tool) print(tool)