cbfstool: Make add-stage support multiple ignore sections

For x86 eXecute-In-Place (XIP) .data section support, cbfstool need to
to skip relocation of the .data section symbols in addition to
.car.data section symbols.

To support this requirement, this patch makes the `-S` option take a
multiple section names separated by commas.

TEST=With `-S ".car.data .data"`, XIP pre-memory stages with
     a `.data` section do not have any of the `.car.data` or `.data`
     section symbols relocated.

Change-Id: Icf09ee5a318e37c5da94bba6c0a0f39485963d3a
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/77560
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Jeremy Compostella
2023-08-30 10:25:33 -07:00
committed by Julius Werner
parent 8bbadded83
commit c9cae530e5
2 changed files with 77 additions and 52 deletions

View File

@@ -46,7 +46,7 @@ static struct param {
const char *region_name;
const char *source_region;
const char *bootblock;
const char *ignore_section;
const char *ignore_sections;
const char *ucode_region;
uint64_t u64val;
uint32_t type;
@@ -1179,9 +1179,9 @@ static int cbfstool_convert_mkstage(struct buffer *buffer, uint32_t *offset,
uint32_t host_space_address = convert_addr_space(param.image_region, *offset);
assert(IS_HOST_SPACE_ADDRESS(host_space_address));
ret = parse_elf_to_xip_stage(buffer, &output, host_space_address,
param.ignore_section, stageheader);
param.ignore_sections, stageheader);
} else {
ret = parse_elf_to_stage(buffer, &output, param.ignore_section,
ret = parse_elf_to_stage(buffer, &output, param.ignore_sections,
stageheader);
}
if (ret != 0)
@@ -1968,7 +1968,8 @@ static void usage(char *name)
" (linux specific: [-C cmdline] [-I initrd]) "
"Add a payload to the ROM\n"
" add-stage [-r image,regions] -f FILE -n NAME [-A hash] \\\n"
" [-c compression] [-b base] [-S section-to-ignore] \\\n"
" [-c compression] [-b base] \\\n"
" [-S comma-separated-section(s)-to-ignore] \\\n"
" [-a alignment] [-Q|--pow2page] \\\n"
" [-y|--xip] [--ibb] \\\n"
" [--ext-win-base win-base --ext-win-size win-size] "
@@ -2271,7 +2272,7 @@ int main(int argc, char **argv)
param.cmdline = optarg;
break;
case 'S':
param.ignore_section = optarg;
param.ignore_sections = optarg;
break;
case 'y':
param.stage_xip = true;