Bug 2419 - broken .eh_frame for one argument syscalls.
Summary: broken .eh_frame for one argument syscalls.
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: nptl (show other bugs)
Version: 2.3.6
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-05 23:50 UTC by dwhedon
Modified: 2018-04-19 13:50 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
patch to fix this bug (559 bytes, patch)
2006-03-05 23:55 UTC, dwhedon
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dwhedon 2006-03-05 23:50:51 UTC
The .eh_frame sections for the nptl single argument syscalls (close and fsync)
in glibc 2.3.6 are being created incorrectly.  Valgrind compains about this, as
discussed here:

http://sourceforge.net/mailarchive/forum.php?thread_id=7568951&forum_id=32038

valgrind emits the message:

DWARF2 CFI reader: unhandled CFI instruction 0:50

on startup of every program linking to the offending object.  This
creates a lot of noise.

readelf agrees that there is a problem with the sections:

$ readelf --debug-dump=frames /lib/tls/libc.so.6 > /dev/null
unsupported or unknown DW_CFA_50
unsupported or unknown DW_CFA_50
$

The patch I will attach shortly fixes the problem.  At least the error message
goes away and to me the CFI instructions now look correct.

FWIW, I noticed the problem on Debian stable (sarge) and current unstable (sid)
but it doesn't look like a Debian only issue.
Comment 1 dwhedon 2006-03-05 23:55:39 UTC
Created attachment 903 [details]
patch to fix this bug

The patch above is far enough removed from the final objects that the
correctness of the fix isn't obvious (to me anyway). To verify the fix I took
the output object and steped through the FDE instructions to create the CFI
table.	Then I checked that the CFI table corresponds to the subroutine in
question.

$ ar -x /usr/lib/nptl/libc.a close.o
$ readelf --debug-dump=frames close.o
The section .eh_frame contains:

00000000 00000010 00000000 CIE
  Version:		 1
  Augmentation: 	 ""
  Code alignment factor: 1
  Data alignment factor: -4
  Return address column: 8

  DW_CFA_def_cfa: r4 ofs 4
  DW_CFA_offset: r8 at cfa-4
  DW_CFA_nop
  DW_CFA_nop

00000014 00000020 00000018 FDE cie=00000000 pc=00000000..00000050
  DW_CFA_advance_loc: 12 to 0000000c
  DW_CFA_register: r3 in r2
  DW_CFA_advance_loc: 13 to 00000019
  DW_CFA_restore: r3
  DW_CFA_advance_loc: 21 to 0000002e
  DW_CFA_register: r3 in r2
  DW_CFA_advance_loc: 13 to 0000003b
  DW_CFA_restore: r3
  DW_CFA_advance_loc: 1 to 0000003c
  DW_CFA_def_cfa_offset: 8
  DW_CFA_advance_loc: 8 to 00000044
  DW_CFA_def_cfa_offset: 4
  DW_CFA_nop
  DW_CFA_nop
$
In order to decode the above I looked at sections 6.4 and Appendix
5 of http://www.arm.com/pdfs/TIS-DWARF2.pdf.  The CFI table described
above is show below.  I also filled in what I believe to be the CFI to
x86 register mapping and the callee saved registers.

				 fp  fp 	 ra
		 eax ecx edx ebx esp ebp esi edi eip
Loc	 CFA	 r0  r1  r2  r3  r4  r5  r6  r7  r8
0	 r4+4	 u   u	 u   s	 u   s	 s   s	 cfa-4
c			     r2
19			     s
2e			     r2
3b			     s
3c	 r4+8
44	 r4+4

key:
  = (blank) same as last (look up in same column to find value)
s = same_value rule
u = undefined rule
rN = register(N) rule

$ objdump -j .text -D close.o

close.o:     file format elf32-i386

Disassembly of section .text:

00000000 <__libc_close>:
   0:	65 83 3d 0c 00 00 00	cmpl   $0x0,%gs:0xc
   7:	00
   8:	75 1b			jne    25 <__close_nocancel+0x1b>

0000000a <__close_nocancel>:
   a:	89 da			mov    %ebx,%edx
   c:	8b 5c 24 04		mov    0x4(%esp),%ebx
  10:	b8 06 00 00 00		mov    $0x6,%eax
  15:	cd 80			int    $0x80
  17:	89 d3			mov    %edx,%ebx
  19:	3d 01 f0 ff ff		cmp    $0xfffff001,%eax
  1e:	0f 83 fc ff ff ff	jae    20 <__close_nocancel+0x16>
  24:	c3			ret
  25:	e8 fc ff ff ff		call   26 <__close_nocancel+0x1c>
  2a:	89 c1			mov    %eax,%ecx
  2c:	89 da			mov    %ebx,%edx
  2e:	8b 5c 24 04		mov    0x4(%esp),%ebx
  32:	b8 06 00 00 00		mov    $0x6,%eax
  37:	cd 80			int    $0x80
  39:	89 d3			mov    %edx,%ebx
  3b:	50			push   %eax
  3c:	89 c8			mov    %ecx,%eax
  3e:	e8 fc ff ff ff		call   3f <__close_nocancel+0x35>
  43:	58			pop    %eax
  44:	3d 01 f0 ff ff		cmp    $0xfffff001,%eax
  49:	0f 83 fc ff ff ff	jae    4b <__close_nocancel+0x41>
  4f:	c3			ret
Comment 2 Ulrich Drepper 2006-04-01 21:48:31 UTC
Irrelevant patch.  We use a completely different method now.  This doesn't mean
the patch is correct and would have been applied.