Bug 12354 - compiling glibc gives "previous cfi entry not closed" while compiling on ARM
Summary: compiling glibc gives "previous cfi entry not closed" while compiling on ARM
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: ports (show other bugs)
Version: 2.12
: P2 normal
Target Milestone: 2.12
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-29 09:23 UTC by michel van der breggen
Modified: 2014-06-27 14:03 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
sigrestorer.s file created by GCC compiler before assembly (563 bytes, text/plain)
2010-12-29 09:23 UTC, michel van der breggen
Details
sigrestorer.s from /sysdeps/unix/sysv/linux/arm folder in glibc source (671 bytes, text/plain)
2010-12-29 09:29 UTC, michel van der breggen
Details
commandline options and output of process (581 bytes, text/plain)
2010-12-29 09:43 UTC, michel van der breggen
Details
proposed patch. Sources have been successfully compiled on armv4l (408 bytes, patch)
2011-09-08 18:26 UTC, Slavanap
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description michel van der breggen 2010-12-29 09:23:14 UTC
Created attachment 5172 [details]
sigrestorer.s file created by GCC compiler before assembly

Trying to compile glibc 2.12 using GCC 4.5.2 and binutils 2.21 gives an unwanted result:

../sysdeps/unix/sysv/linux/arm/sigrestorer.S: Assembler messages:
../sysdeps/unix/sysv/linux/arm/sigrestorer.S:30: Error: previous CFI entry not closed (missing .cfi_endproc)
../sysdeps/unix/sysv/linux/arm/sigrestorer.S:31: Error: open CFI at the end of file; missing .cfi_endproc directive

I've seen a similiar bug in 2006 on the alpha platform but that was patched in GAS.

System is a ARM armv5tejl, using arm-none-linux-gnueabi compile options. The current binutils, compiler and libraries are installed as "optware" meaning all files are stored in /opt due to size limitations on the flash memory.

Attached are the sigrestorer.S sigrestorer.s and the compile log.

The result should have been a compiled and assembled sigrestorer.o
Comment 1 michel van der breggen 2010-12-29 09:29:25 UTC
Created attachment 5173 [details]
sigrestorer.s from /sysdeps/unix/sysv/linux/arm folder in glibc source
Comment 2 michel van der breggen 2010-12-29 09:43:06 UTC
Created attachment 5174 [details]
commandline options and output of process
Comment 3 michel van der breggen 2011-01-05 21:12:57 UTC
I've been digging around in the created .s file and found that it indeed does not create correct cfi information. At some point cfi information is placed without actually setting an cfi_startproc or no cfi_endproc is included. 

What I think is that the implementation of cfi commands for the ARM is not completely implemented correctly because in DOARGS and UNDOARGS ( in /sysdeps/unix/sysv/linux/arm/sysdep.h ) no check is made of the cfi is indeed within start-end pattern.
Comment 4 jsm-csl@polyomino.org.uk 2011-01-05 21:59:49 UTC
I think you are making things much more complicated than necessary.  It 
seems more likely that all that's needed is adding END calls to match the 
ENTRY ones in sysdeps/unix/sysv/linux/arm/sigrestorer.S.  Note that 
old-ABI has been essentially unmaintained for a long time now; I strongly 
recommend moving to EABI.  sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S 
has the END calls and the file you reference should not be used at all in 
an EABI build.
Comment 5 Rene Berber 2011-09-08 00:21:53 UTC
(In reply to comment #4)
> I think you are making things much more complicated than necessary.  It 
> seems more likely that all that's needed is adding END calls to match the 
> ENTRY ones in sysdeps/unix/sysv/linux/arm/sigrestorer.S.  Note that 
> old-ABI has been essentially unmaintained for a long time now; I strongly 
> recommend moving to EABI.  sysdeps/unix/sysv/linux/arm/eabi/sigrestorer.S 
> has the END calls and the file you reference should not be used at all in 
> an EABI build.

I stumbled on the same bug, with glibc 2.12.2 and glibc-ports 2.12.1 (there is no corresponding release), and using gcc 4.5.3 and binutils 2.21.1.

But the interesting point is that both Michel and me are using gnueabi, which is not the old abi (for instance 'objdump -x as' | grep private' returns "private flags = 4000002: [Version4 EABI] [has entry point]").

The bug seems to be what you point out, somehow the old abi is used.

Could be a bug in the ports add-on.
Comment 6 Slavanap 2011-09-08 18:26:22 UTC
Created attachment 5924 [details]
proposed patch. Sources have been successfully compiled on armv4l
Comment 7 Rene Berber 2011-09-08 20:32:44 UTC
On my end the problem still seems to be configure misidentifying the build.

With no --build configure shows "host system type... armv5tejl-unknown-linux-gnu".  Which is wrong.

With --build=... "host system type... armv5tejl-unknown-linux-gnueabi".

FWIW trying the patch with the wrong ABI resolves the problem with sigrestorer.S, but the same error shows later with sysdeps/unix/syscall-template.S .
Comment 8 Rene Berber 2011-09-08 23:27:27 UTC
The problem with configure guessing wrong the build system type comes from before, glibc-2.11.3 has the same problem; and it was fixed on newer versions 2.13 and 2.14 don't have the problem.
Comment 9 Mike Frysinger 2012-01-03 00:37:33 UTC
posted a patch here:
http://sourceware.org/ml/libc-ports/2012-01/msg00003.html
Comment 10 Mike Frysinger 2012-01-09 19:04:36 UTC
changes have been committed to the ports tree now
Comment 11 Jackie Rosen 2014-02-16 18:23:45 UTC Comment hidden (spam)