Fix chip info in the ROM/ROM_EXT #28418
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While looking at the chip info, I realized that there were several problems. Originally, the issue comes from the fact that we have a single
cc_library
that contains both thechip_info.h
header and thechip_info.c
data. This means that any binary using this dependency ends up including thekChipInfo
data even if they didn't intend to. Coupled with the fact that several pieces of code directly refer tokChipInfo
instead of the linker symbol_chip_info_start
means that for example part of the ROM_EXT doesn't actually read from the ROM's chip_info but from a ROM_EXT-embedded chip info!I decided to fix that by splitting the library into the header (which is what everyone but the ROM should use) and the data. I also eliminated the
kChipInfo
symbol from the header entirely and replaced all users with_chip_info_start
. While doing so, I stumbled on a subtle linker problem which is that sincekChipInfo
becomes unused, it won't participate in linking (even if the section is marked as NODISARD) unless--whole-archive
is used which fortunaltely bazel has a setting for (alwayslink=True
).I also decided to create a new ROM end-to-end test for the chip info to make sure that the data is present there. Maybe it might be worth also create a ROM_EXT end-to-end test to make sure that it uses the ROM chip info and not some other chip info but I leave that to a future PR.