zephyr/scripts
Martí Bolívar a627666e06 device: add fudge factor for handle padding
When CONFIG_USERSPACE is enabled, the ELF file from linker pass 1 is
used to create a hash table that identifies kernel objects by address.
We therefore can't allow the size of any object in the pass 2 ELF to
change in a way that would change those addresses, or we would create
a garbage hash table.

Simultaneously (and regardless of CONFIG_USERSPACE's value),
gen_handles.py must transform arrays of handles from their pass 1
values to their pass 2 values; see the file's docstring for more
details on that transformation.

The way this works is that gen_handles.py just pads out each pass 2
array so its length is the same as its pass 1 value. The padding value
is a repeated run of DEVICE_HANDLE_ENDS values. This value is the
terminator which we look for at runtime in places like
device_required_handles_get(), so there must be at least one, and we
error out in gen_handles.py if there's no room in the pass 2 array for
at least one such value. (If there is extra room, we just keep
inserting extra DEVICE_HANDLE_ENDS values to pad the array to its
original length.)

However, it is possible that a device has more direct dependencies in
the pass 2 handles array than its corresponding devicetree node had in
the pass 1 array. When this happens, users have no recourse, so that's
a potential showstopper.

To work around this possibility for now, add a new config option,
CONFIG_DEVICE_HANDLE_PADDING, whose value defaults to 0.

When nonzero, it is a count of padding handles that are inserted into
each device handles array. When gen_handles.py errors out due to lack
of room, its error message now tells the user how much to increase
CONFIG_DEVICE_HANDLE_PADDING by to work around the problem.

It looks like a real fix for this is to allocate kernel objects whose
addresses are required for hash tables in CONFIG_USERSPACE=y
configurations *before* the handle arrays. The handle arrays could
then be resized as needed in pass 2, which saves ROM by avoiding
unnecessary padding, and would avoid the need for
CONFIG_DEVICE_HANDLE_PADDING altogether.

However, this 'real fix' is not available and we are facing a deadline
to get a temporary solution in for Zephyr v2.7.0, so this is a good
enough workaround for now.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-09-30 21:37:59 -04:00
..
checkpatch kernel: add an architecture specific structs header 2021-04-21 09:03:47 -04:00
ci scripts: check_compliance should not generate soc/shield Kconfig files 2021-09-23 11:27:41 -04:00
coccinelle coccinelle: check reserved symbols based on a file 2021-04-30 22:09:43 -04:00
coredump scripts: coredump: rename parser to avoid conflict with builtin module 2021-07-19 21:14:16 +03:00
dts dtlib: fix issue which allowed invalid node names 2021-08-31 19:36:31 -04:00
footprint scripts: Track memory footprint for networking samples on frdm_k64f 2021-08-03 07:10:09 -04:00
gitlint zephyr_commit_rules.py: Fix pylint warning by simplifying conditional 2019-09-08 22:19:37 -04:00
kconfig net: ptp: extract PTP interfaces outside gPTP subsys under NET_L2_PTP 2021-09-28 20:01:16 -04:00
logging/dictionary scripts: colorize parsed dictionary logging 2021-07-16 21:34:06 -04:00
net net: scripts: Make test runner script fully generic 2020-11-20 16:07:59 +02:00
pylib/twister twister: Fix missing testcases with error status 2021-09-28 21:34:10 -04:00
release scripts: add script to extract top-ten bug-bashers 2021-09-01 17:06:50 -04:00
schemas/twister sanitycheck: Add a feature which can handle pytest script. 2021-05-04 19:08:18 -04:00
support scripts: Simplify code with sys.exit(<string>) 2019-09-08 12:34:16 +02:00
tests twister: remove toolchain test 2021-06-11 08:16:41 -04:00
tracing tracing: scripts: add scripts for parsing ctf data 2020-08-24 13:21:12 +02:00
west_commands west: sign: add support for NXP i.MX8QXP board 2021-09-27 21:52:31 -04:00
.gitignore cleanup: rename sanitycheck references to twister 2021-01-14 07:50:52 -06:00
checkpatch.pl scripts: checkpatch: do not require top-level Makefile 2021-03-29 10:59:28 -04:00
checkstack.pl
coccicheck scripts: Fix documunt referenc for coccicheck 2020-05-08 17:44:44 +02:00
dir_is_writeable.py global: Remove leading/trailing blank lines in files 2019-12-11 19:17:27 +01:00
file2hex.py scripts: file2hex.py: PEP 8 style fix 2020-06-12 11:09:58 +02:00
gen_app_partitions.py scripts: Add align for empty _app_smem region 2021-09-28 20:06:06 -04:00
gen_cfb_font_header.py zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
gen_gcov_files.py scripts: gen_gcov_files.py: add argument help text 2020-06-13 16:33:22 -04:00
gen_handles.py device: add fudge factor for handle padding 2021-09-30 21:37:59 -04:00
gen_kobject_list.py kernel: app_smem: allowing pinning memory partitions 2021-08-26 21:16:22 -04:00
gen_kobject_placeholders.py kernel: generate placeholders for kobj tables before final build 2021-04-27 13:32:00 -04:00
gen_offset_header.py scripts: gen_offset_header: add argument help text 2020-05-21 14:45:24 +02:00
gen_relocate_app.py scripts: Set align size for code relocated 2021-05-04 15:46:52 +02:00
gen_syscalls.py kernel: syscall: pin generated inline functions 2021-08-26 21:16:22 -04:00
get_maintainer.py scripts: add maintainer script 2020-07-24 17:07:48 +02:00
list_boards.py scripts: list_boards: handle boards dirs with subset of architectures 2021-06-11 16:26:30 +02:00
mergehex.py scripts: cmake: move print from python to cmake 2020-01-03 08:20:08 -05:00
parse_syscalls.py userspace: net sockets are kernel objects 2020-06-03 22:33:32 +02:00
process_gperf.py scripts: process_gperf: typo fix 2020-06-09 10:40:58 +02:00
requirements-base.txt requirements: bump west to >=0.10.1 2021-05-18 09:52:12 -05:00
requirements-build-test.txt scripts: move pip pykwalify from requirements-build-test to -base 2021-01-18 16:56:24 -05:00
requirements-compliance.txt requirements-compliance: restrict junitparser version < 2 2021-01-13 07:58:37 -05:00
requirements-doc.txt requirements-doc: add PyYAML which removes dependency on -base 2021-06-16 10:39:08 +02:00
requirements-extras.txt scripts: add script to extract top-ten bug-bashers 2021-09-01 17:06:50 -04:00
requirements-run-test.txt requirements: Update to pyocd 0.29 for LPC55S69 support 2021-01-21 15:53:22 -05:00
requirements.txt python3: add check_compliance package requirements 2020-08-11 14:49:48 -04:00
series-push-hook.sh scripts: series-push-hook: Use main as base comparison branch 2021-05-27 15:55:43 -05:00
spelling.txt scripts: updated spelling.txt file 2017-07-14 12:57:40 +03:00
subfolder_list.py scripts: subfolder_list.py: refactor the code 2020-07-20 17:31:53 -04:00
tags.sh scripts: Update paths on tags.sh 2021-02-19 05:28:09 -06:00
twister twister: improve set balancing 2021-04-22 21:15:07 -04:00
uf2conv.py cmake: Add UF2 as an additional build output option. 2021-02-23 21:11:04 +01:00
user_wordsize.py posix arch: build on aarch64 / allow host-specific cmake includes 2020-05-09 12:17:24 +02:00
valgrind.supp lvgl: Suppress memory leak errors detected by valgrind 2019-10-21 12:26:35 -07:00
west-commands.yml west: spdx: Generate SPDX 2.2 tag-value documents 2021-05-05 11:14:06 -04:00
zephyr_module.py cmake: add a comment header to zephyr_settings.txt 2021-08-10 07:37:19 -04:00