Subject: bug#20614: Segmentation fault when building on Power8 Little Endian

From: Petr Hracek <[email-masked]>
Date: Fri, 2 Oct 2015 10:36:27 +0200

On 10/01/2015 06:01 PM, Eli Zaretskii wrote:
>> Cc: [email-masked]
>> From: Petr Hracek <[email-masked]>
>> Date: Thu, 1 Oct 2015 16:05:57 +0200
>>
>> (gdb) bt full
>> #0  0x00003fffb5a9a870 in strcmp () at /lib64/power8/libc.so.6
>> #1  0x00000000102e3724 in unexec (new_name=0x116387e8
>> "/home/phracek/rpmbuild/BUILD/emacs-24.3/src/emacs", old_name=0x11638838
>> "/home/phracek/rpmbuild/BUILD/emacs-24.3/src/temacs") at unexelf.c:1258
>>           section =
>>             {sh_name = 122, sh_type = 4, sh_flags = 2, sh_addr =
>> 268483528, sh_offset = 48072, sh_size = 768, sh_link = 5, sh_info = 0,
>> sh_addralign = 8, sh_entsize = 24}
> What does this GDB command display in frame #1:
>
>    (gdb) p old_section_names + NEW_SECTION_H (nn).sh_name
>
> ?
It is a really strange.
in our unexelf.c is NEW_SECTION_H defined as

#define NEW_SECTION_H(n) \
      (*(ElfW (Shdr) *) ((byte *) new_section_h + 
new_file_h->e_shentsize * (n)))

Paul Eggert did a some patch 1 or 2 year ago and modify it to

|#define NEW_SECTION_H(n) \ (*(ElfW (Shdr) *) entry_address 
(new_section_h, n, new_file_h->e_shentsize))|

(gdb) frame 1
#1  0x00000000102e3724 in unexec (new_name=0x116387e8 
"/home/phracek/rpmbuild/BUILD/emacs-24.3/src/emacs", old_name=0x11638838 
"/home/phracek/rpmbuild/BUILD/emacs-24.3/src/temacs")
     at unexelf.c:1258
1258          if (!strcmp (old_section_names + NEW_SECTION_H 
(nn).sh_name, ".data")
(gdb) p old_section_names
$1 = 0x3fffab1dbfcc ""
(gdb) p old_section_names + NEW_SECTION_H (nn).sh_name
No symbol "NEW_SECTION_H" in current context.
(gdb) info frame
Stack level 1, frame at 0x3fffffffd9d0:
  pc = 0x102e3724 in unexec (unexelf.c:1258); saved pc 0x101a1170
  called by frame at 0x3fffffffda70, caller of frame at 0x3fffffffd770
  source language c.
  Arglist at 0x3fffffffd770, args: new_name=0x116387e8 
"/home/phracek/rpmbuild/BUILD/emacs-24.3/src/emacs", old_name=0x11638838 
"/home/phracek/rpmbuild/BUILD/emacs-24.3/src/temacs"
  Locals at 0x3fffffffd770, Previous frame's sp is 0x3fffffffd9d0
  Saved registers:
   r30 at 0x3fffffffd9c0, r31 at 0x3fffffffd9c8, pc at 0x3fffffffd9e0, 
lr at 0x3fffffffd9e0
(gdb) info locals
section = {sh_name = 122, sh_type = 4, sh_flags = 2, sh_addr = 
268483528, sh_offset = 48072, sh_size = 768, sh_link = 5, sh_info = 0, 
sh_addralign = 8, sh_entsize = 24}
new_file = 10
old_file = 9
new_file_size = 30790315
new_break = 0x116f0000
old_base = 0x3fffaa800000 "\177ELF\002\001\001"
new_base = 0x3fffa8aa0000 "\177ELF\002\001\001"
old_file_h = 0x3fffaa800000
new_file_h = 0x3fffa8aa0000
old_program_h = 0x3fffaa800040
new_program_h = 0x3fffa8aa0040
old_section_h = 0x3fffab1dc110
new_section_h = 0x3fffaa78c110
old_section_names = 0x3fffab1dbfcc ""
old_bss_addr = 272498688
new_bss_addr = 292487168
old_bss_size = 563072
new_data2_size = 19988480
new_data2_offset = 4063232
new_data2_addr = 272498688
old_bss_offset = 4063232
new_data2_incr = 19988480
n = 9
nn = 0
old_bss_index = 22
old_sbss_index = -1
old_plt_index = 20
old_data_index = 21
new_data2_index = 20
stat_buf = {st_dev = 2050, st_ino = 5119871, st_nlink = 1, st_mode = 
33261, st_uid = 20582, st_gid = 20582, __pad2 = 0, st_rdev = 0, st_size 
= 10801771, st_blksize = 4096,
   st_blocks = 20984, st_atim = {tv_sec = 1443772792, tv_nsec = 
166219486}, st_mtim = {tv_sec = 1443772792, tv_nsec = 46219474}, st_ctim 
= {tv_sec = 1443772792, tv_nsec = 46219474},
   __unused4 = 0, __unused5 = 0, __unused6 = 0}
old_file_size = 10801771
(gdb) info args
new_name = 0x116387e8 "/home/phracek/rpmbuild/BUILD/emacs-24.3/src/emacs"
old_name = 0x11638838 "/home/phracek/rpmbuild/BUILD/emacs-24.3/src/temacs"

-- 
Petr Hracek
Software Engineer
Developer Experience
Red Hat, Inc
Mob: +420777056169
email: [email-masked]