Skip to content

Commit

Permalink
build_system: Cleanup access to ".intList" section
Browse files Browse the repository at this point in the history
This commit changes the way ".intList" section is handled by the build system.
Now it is marked as INFO section - that means it would not be available as an output
and does not need to be placed in any memory segment.
It cannot by accessed by objcopy, but can be accessed by elftools instead.

Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
  • Loading branch information
rakons committed Jul 31, 2023
1 parent 00f0054 commit 8ea5397
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 30 deletions.
11 changes: 1 addition & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1242,20 +1242,11 @@ if(CONFIG_GEN_ISR_TABLES)
# isr_tables.c is generated from ${ZEPHYR_LINK_STAGE_EXECUTABLE} by
# gen_isr_tables.py
add_custom_command(
OUTPUT isr_tables.c isrList.bin
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
$<TARGET_PROPERTY:bintools,elfconvert_flag>
$<TARGET_PROPERTY:bintools,elfconvert_flag_intarget>${OUTPUT_FORMAT}
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>binary
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_only>.intList
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>$<TARGET_FILE:${ZEPHYR_LINK_STAGE_EXECUTABLE}>
$<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>isrList.bin
$<TARGET_PROPERTY:bintools,elfconvert_flag_final>
OUTPUT isr_tables.c
COMMAND ${PYTHON_EXECUTABLE}
${ZEPHYR_BASE}/scripts/build/gen_isr_tables.py
--output-source isr_tables.c
--kernel $<TARGET_FILE:${ZEPHYR_LINK_STAGE_EXECUTABLE}>
--intlist isrList.bin
$<$<BOOL:${CONFIG_BIG_ENDIAN}>:--big-endian>
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--debug>
${GEN_ISR_TABLE_EXTRA_ARG}
Expand Down
2 changes: 1 addition & 1 deletion arch/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ zephyr_linker_sources_ifdef(CONFIG_GEN_IRQ_VECTOR_TABLE
)

if(CONFIG_GEN_ISR_TABLES)
zephyr_linker_section(NAME .intList VMA IDT_LIST LMA IDT_LIST NOINPUT PASS NOT LINKER_ZEPHYR_FINAL)
zephyr_linker_section(NAME .intList NOINPUT PASS NOT LINKER_ZEPHYR_FINAL)
zephyr_linker_section_configure(SECTION .intList KEEP INPUT ".irq_info" FIRST)
zephyr_linker_section_configure(SECTION .intList KEEP INPUT ".intList")

Expand Down
15 changes: 2 additions & 13 deletions include/zephyr/linker/intlist.ld
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,14 @@
* defined, the total number of IRQ lines in the system, followed by
* an appropriate number of instances of struct _isr_list. See
* include/sw_isr_table.h
*
* You will need to declare a bogus memory region for IDT_LIST. It doesn't
* matter where this region goes as it is stripped from the final ELF image.
* The address doesn't even have to be valid on the target. However, it
* shouldn't overlap any other regions. On most arches the following should be
* fine:
*
* MEMORY {
* .. other regions ..
* IDT_LIST : ORIGIN = 0xfffff7ff, LENGTH = 2K
* }
*/

#ifndef LINKER_ZEPHYR_FINAL
SECTION_PROLOGUE(.intList,,)
SECTION_PROLOGUE(.intList, 0 (INFO),)
{
KEEP(*(.irq_info*))
KEEP(*(.intList*))
} GROUP_ROM_LINK_IN(IDT_LIST, IDT_LIST)
}
#else
/DISCARD/ :
{
Expand Down
13 changes: 7 additions & 6 deletions scripts/build/gen_isr_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def endian_prefix():
else:
return "<"

def read_intlist(intlist_path, syms):
def read_intlist(elfobj, syms):
"""read a binary file containing the contents of the kernel's .intList
section. This is an instance of a header created by
include/zephyr/linker/intlist.ld:
Expand Down Expand Up @@ -75,8 +75,11 @@ def read_intlist(intlist_path, syms):
else:
intlist_entry_fmt = prefix + "iiII"

with open(intlist_path, "rb") as fp:
intdata = fp.read()
intList_sect = elfobj.get_section_by_name(".intList")
if intList_sect is None:
error("Empty \".intList\" section!")

intdata = intList_sect.data()

header_sz = struct.calcsize(intlist_header_fmt)
header = struct.unpack_from(intlist_header_fmt, intdata, 0)
Expand Down Expand Up @@ -120,8 +123,6 @@ def parse_args():
help="Generate SW ISR table")
parser.add_argument("-V", "--vector-table", action="store_true",
help="Generate vector table")
parser.add_argument("-i", "--intlist", required=True,
help="Zephyr intlist binary for intList extraction")

args = parser.parse_args()

Expand Down Expand Up @@ -236,6 +237,7 @@ def main():
with open(args.kernel, "rb") as fp:
kernel = ELFFile(fp)
syms = get_symbols(kernel)
intlist = read_intlist(kernel, syms)

if "CONFIG_MULTI_LEVEL_INTERRUPTS" in syms:
max_irq_per = syms["CONFIG_MAX_IRQ_PER_AGGREGATOR"]
Expand All @@ -258,7 +260,6 @@ def main():

debug('3rd level offsets: {}'.format(list_3rd_lvl_offsets))

intlist = read_intlist(args.intlist, syms)
nvec = intlist["num_vectors"]
offset = intlist["offset"]

Expand Down

0 comments on commit 8ea5397

Please sign in to comment.