Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 109666 - sys-apps/util-linux-2.12r -fPIC problems in fdisk/llseek.c
Summary: sys-apps/util-linux-2.12r -fPIC problems in fdisk/llseek.c
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: Highest major (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-17 22:44 UTC by Cory Visi (RETIRED)
Modified: 2005-10-21 15:09 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
util-linux-2.12r-lseek64.patch (util-linux-2.12r-lseek64.patch,4.51 KB, patch)
2005-10-17 22:45 UTC, Cory Visi (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cory Visi (RETIRED) gentoo-dev 2005-10-17 22:44:04 UTC
sys-apps/util-linux-2.12r, sys-apps/util-linux-2.12r-r1
Hardened 2005.1 profile, x86

Here's the error:

i486-pc-linux-gnu-gcc -c  -I../lib -Wall -Wmissing-prototypes -Wstrict-prototypes -DNCH=1  -
DDISABLE_NLS -D_FILE_OFFSET_BITS=64 -DSBINDIR=\"/sbin\" -DUSRSBINDIR=\"/usr/
sbin\" -DLOGDIR=\"/var/log\" -DVARPATH=\"/var\" -DLOCALEDIR=\"/usr/share/locale\" -O2 
llseek.c -o llseek.o
llseek.c: In function `_llseek':
llseek.c:34: error: can't find a register in class `BREG' while reloading `asm'
make: *** [llseek.o] Error 1

This is a problem with the _llseek function using _syscall5().  We've seen this before: Bug 51962 
and there are probably many others.  This is going to affect x86 hardened users mostly, because 
they have fewer registers to implement -fPIC (amd64 hardened, for instance, will not see this 
error).

This is not new, but recently a change has been made to reintroduce the problem.  Here's the 
history (from ChangeLog):
12 Jul 2003 Solar adds -pic patch to avoid _syscall5 (2.11z-r5)
05 Oct 2005 Mike siliently removes the -pic patch (2.12r)
15 Oct 2005 Solar adds a fix for a related issue, but it still doesn't compile on x86 hardened (2.
12r-r1)

I think the right way to fix this problem is to use lseek64, which is discussed at length in Bug 
51962.  Specifically Comment #5 gives a brief history of the _llseek mess and ending comments 
confirm that the lseek64 fix was a success.  Please please please read it.

I've attached a patch to fix up util-linux properly, and I'd love to see it included in mainstream.  It 
compiles on x86 hardened and amd64 hardened nicely.  I've CC'd Adrian Bunk (current util-linux 
maintainer) on this.  Hopefully, I'm not wasting your time Adrian, and this is a good idea.

I'm not including a patch for the ebuild, because it's trivial to add an epatch line in.  It can be at 
the top of the list or the bottom.
Comment 1 Cory Visi (RETIRED) gentoo-dev 2005-10-17 22:45:28 UTC
Created attachment 70900 [details, diff]
util-linux-2.12r-lseek64.patch

Patch to replace _llseek selection login with lseek64 as recommended by the
glibc development team.
Comment 2 SpanKY gentoo-dev 2005-10-17 22:48:43 UTC
Comment on attachment 70900 [details, diff]
util-linux-2.12r-lseek64.patch

no, correct fix is to patch linux-headers-2.4 like we do with 2.6
Comment 3 Cory Visi (RETIRED) gentoo-dev 2005-10-17 23:09:31 UTC
I'm closing this bug, because Gentoo's current fix for this is to patch the _syscall macros in the 
Linux Kernel headers to be PIC safe (Bug 49826).

I was using my own cleansed version of 2.6.13 userspace headers, which is why I had the 
problem in the first place.

I still think that this patch is worth consideration, so I will correspond with Adrian offline.  But it 
definitely belongs in util-linux mainstream, not in the Gentoo ebuild, since Gentoo has a solution 
already.

I also think the PIC-safe _syscall macros really should be sent to the kernel development team 
for consideration in whatever version they deem appropriate.  Do we really want to maintain 
assembly code in the kernel?
Comment 4 Kevin F. Quinn (RETIRED) gentoo-dev 2005-10-17 23:21:19 UTC
(that reference should be bug #79939)

Comment 5 Adrian Bunk 2005-10-18 04:08:45 UTC
(In reply to comment #1)
> Created an attachment (id=70900) [edit]
> util-linux-2.12r-lseek64.patch
> 
> Patch to replace _llseek selection login with lseek64 as recommended by the
> glibc development team.

In 2.13-pre5, I've already removed llseek.c and switched to use plain lseek
everywhere.

This should work on every LFS-compliant system (configure sets _FILE_OFFSET_BITS
in config.h and every file #include's config.h).

Please tell if there's any problem with my approach.
Comment 6 Adrian Bunk 2005-10-21 15:09:54 UTC
(In reply to comment #5)
> (In reply to comment #1)
> > Created an attachment (id=70900) [edit] [edit]
> > util-linux-2.12r-lseek64.patch
> > 
> > Patch to replace _llseek selection login with lseek64 as recommended by the
> > glibc development team.
> 
> In 2.13-pre5, I've already removed llseek.c and switched to use plain lseek
> everywhere.
>...

My bad, that's not in the released -pre5 but in the -pre6 I'm currently working on.