Skip to content

Commit

Permalink
improve error when ".rackboot" section is stripped
Browse files Browse the repository at this point in the history
Detect the case that a ".rackboot" ELF section is expected to be
present but isn't found, instead of failing with a more obscure
message about the format of the `petite` boot image.
  • Loading branch information
mflatt committed Apr 26, 2024
1 parent a04dffe commit 5713201
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions racket/src/cs/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,17 @@ static char *path_append_2(const char *p1, const char *p2) {
#endif

#if !defined(WIN32) && !defined(OS_X)
static long find_boot_section(const char *me)
static long find_boot_section(const char *me, int must_find)
{
int start = 0, end = 0;

find_elf_section_offset(me, ".rackboot", &start, &end);

if (start == 0 && must_find) {
fprintf(stderr, "%s: ELF section \".rackboot\" is missing\n", me);
exit(1);
}

return start;
}
#endif
Expand Down Expand Up @@ -202,7 +207,11 @@ static int bytes_main(int argc, char **argv,
else
boot_offset = 0;
#else
boot_offset = find_boot_section(boot_exe);
boot_offset = find_boot_section(boot_exe,
/* If the first offset is 0 and the second is not,
then the intent must be for those offsets to
be relative to a boot section: */
(boot1_offset == 0) && (boot2_offset > 0));
#endif

boot1_offset += boot_offset;
Expand Down

0 comments on commit 5713201

Please sign in to comment.