]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Treat 16-bit sections as hidden in hybrid binaries
authorMichael Brown <mcb30@ipxe.org>
Fri, 24 Nov 2023 12:16:49 +0000 (12:16 +0000)
committerMichael Brown <mcb30@ipxe.org>
Fri, 24 Nov 2023 12:16:49 +0000 (12:16 +0000)
Hybrid bzImage and UEFI binaries (such as wimboot) may include 16-bit
sections such as .bss16 that do not need to consume an entry in the PE
section list.  Treat any such sections as hidden.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/util/elf2efi.c

index c98c4d4a909fb2d74a7d3d53e5e06d52b595e3fb..171e2b58ccb37efc70767cc38ef2308e11026630 100644 (file)
@@ -653,6 +653,12 @@ static struct pe_section * process_section ( struct elf_file *elf,
                }
        }
 
+       /* Treat 16-bit sections as hidden in hybrid binaries */
+       if ( opts->hybrid && ( strlen ( name ) > 2 ) &&
+            ( strcmp ( &name[ strlen ( name ) - 2 ], "16" ) == 0 ) ) {
+               new->hidden = 1;
+       }
+
        /* Fill in section characteristics and update RVA limits */
        if ( ( shdr->sh_type == SHT_PROGBITS ) &&
             ( shdr->sh_flags & SHF_WRITE ) ) {