Advertisement
Guest User

Untitled

a guest
Nov 9th, 2021
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.74 KB | None | 0 0
  1. static bool
  2. elf_i386_fake_sections (bfd *abfd ATTRIBUTE_UNUSED,
  3. Elf_Internal_Shdr *hdr,
  4. asection *sec)
  5. {
  6. const char *name;
  7.  
  8. name = bfd_section_name (sec);
  9.  
  10. /* This is an ugly, but unfortunately necessary hack that is
  11. needed when producing EFI binaries on x86. It tells
  12. elf.c:elf_fake_sections() not to consider ".reloc" as a section
  13. containing ELF relocation info. We need this hack in order to
  14. be able to generate ELF binaries that can be translated into
  15. EFI applications (which are essentially COFF objects). Those
  16. files contain a COFF ".reloc" section inside an ELFNN object,
  17. which would normally cause BFD to segfault because it would
  18. attempt to interpret this section as containing relocation
  19. entries for section "oc". With this hack enabled, ".reloc"
  20. will be treated as a normal data section, which will avoid the
  21. segfault. However, you won't be able to create an ELFNN binary
  22. with a section named "oc" that needs relocations, but that's
  23. the kind of ugly side-effects you get when detecting section
  24. types based on their names... In practice, this limitation is
  25. unlikely to bite. */
  26. if (strcmp (name, ".reloc") == 0)
  27. hdr->sh_type = SHT_PROGBITS;
  28.  
  29. return true;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement