patch-src_unexelf_c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. $OpenBSD: patch-src_unexelf_c,v 1.3 2016/06/28 14:06:59 kettenis Exp $
  2. --- src/unexelf.c.orig Tue Oct 15 16:21:44 2002
  3. +++ src/unexelf.c Mon Jun 27 23:19:45 2016
  4. @@ -460,7 +460,7 @@ extern void fatal (char *, ...);
  5. #define MAP_FAILED ((void *) -1)
  6. #endif
  7. -#if defined (__alpha__) && !defined (__NetBSD__) && !defined (__OpenBSD__)
  8. +#if defined (__alpha__) && !defined (__NetBSD__)
  9. /* Declare COFF debugging symbol table. This used to be in
  10. /usr/include/sym.h, but this file is no longer included in Red Hat
  11. 5.0 and presumably in any other glibc 2.x based distribution. */
  12. @@ -549,10 +549,12 @@ typedef struct {
  13. # else
  14. # define ElfBitsW(bits, type) Elf/**/bits/**/_/**/type
  15. # endif
  16. -# ifdef _LP64
  17. -# define ELFSIZE 64
  18. -# else
  19. -# define ELFSIZE 32
  20. +# ifndef __OpenBSD__
  21. +# ifdef _LP64
  22. +# define ELFSIZE 64
  23. +# else
  24. +# define ELFSIZE 32
  25. +# endif
  26. # endif
  27. /* This macro expands `bits' before invoking ElfBitsW. */
  28. # define ElfExpandBitsW(bits, type) ElfBitsW (bits, type)
  29. @@ -753,10 +755,12 @@ unexec (new_name, old_name, data_start, bss_start, ent
  30. old_bss_index = find_section (".bss", old_section_names,
  31. old_name, old_file_h, old_section_h, 0);
  32. +#ifndef __powerpc__
  33. old_sbss_index = find_section (".sbss", old_section_names,
  34. old_name, old_file_h, old_section_h, 1);
  35. if (old_sbss_index != -1)
  36. if (OLD_SECTION_H (old_sbss_index).sh_type == SHT_PROGBITS)
  37. +#endif
  38. old_sbss_index = -1;
  39. if (old_sbss_index == -1)
  40. @@ -786,8 +790,16 @@ unexec (new_name, old_name, data_start, bss_start, ent
  41. #endif
  42. new_data2_addr = old_bss_addr;
  43. new_data2_size = new_bss_addr - old_bss_addr;
  44. +#if defined (__hppa__) || defined (__powerpc__)
  45. + new_data2_offset = OLD_SECTION_H (old_bss_index).sh_offset +
  46. + (new_data2_addr - OLD_SECTION_H (old_bss_index).sh_addr);
  47. + new_data2_offset =
  48. + round_up (new_data2_offset,
  49. + OLD_SECTION_H (old_bss_index).sh_addralign);
  50. +#else
  51. new_data2_offset = OLD_SECTION_H (old_data_index).sh_offset +
  52. (new_data2_addr - OLD_SECTION_H (old_data_index).sh_addr);
  53. +#endif
  54. #ifdef DEBUG
  55. fprintf (stderr, "old_bss_index %d\n", old_bss_index);
  56. @@ -891,6 +903,9 @@ unexec (new_name, old_name, data_start, bss_start, ent
  57. /* Make sure that the size includes any padding before the old .bss
  58. section. */
  59. +#if defined (__hppa__) || defined (__powerpc__)
  60. + NEW_PROGRAM_H (n).p_offset = new_data2_offset;
  61. +#endif
  62. NEW_PROGRAM_H (n).p_filesz = new_bss_addr - NEW_PROGRAM_H (n).p_vaddr;
  63. NEW_PROGRAM_H (n).p_memsz = NEW_PROGRAM_H (n).p_filesz;