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
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
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
tests twister: remove toolchain test 2021-06-11 08:16:41 -04:00
tracing
west_commands west: sign: add support for NXP i.MX8QXP board 2021-09-27 21:52:31 -04:00
.gitignore
checkpatch.pl scripts: checkpatch: do not require top-level Makefile 2021-03-29 10:59:28 -04:00
checkstack.pl
coccicheck
dir_is_writeable.py
file2hex.py
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
gen_gcov_files.py
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
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
list_boards.py scripts: list_boards: handle boards dirs with subset of architectures 2021-06-11 16:26:30 +02:00
mergehex.py
parse_syscalls.py
process_gperf.py
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-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
series-push-hook.sh scripts: series-push-hook: Use main as base comparison branch 2021-05-27 15:55:43 -05:00
spelling.txt
subfolder_list.py
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
valgrind.supp
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