Bug 882321 - file reports "unknown capability 0x41000000 = 0xf676e75" on PPC32 binaries
Summary: file reports "unknown capability 0x41000000 = 0xf676e75" on PPC32 binaries
Alias: None
Product: Fedora
Classification: Fedora
Component: file
Version: 18
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Jan Kaluža
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2012-11-30 16:54 UTC by Petr Machata
Modified: 2015-05-05 01:37 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2013-03-22 10:11:27 UTC
Type: Bug

Attachments (Terms of Use)

Description Petr Machata 2012-11-30 16:54:04 UTC
Description of problem:
On a PPC32 binary built on Fedora 16, "file" gives the following description:

ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1, dynamically linked (uses shared libs), for GNU/Linux 2.6.32, with unknown capability 0x41000000 = 0xf676e75, with unknown capability 0x10000 = 0x70401, stripped

The capabilities are wrong.  file sees a section with type 0x6ffffff5 and assumes it's SHT_SUNW_cap section.  With GNU binaries (ELF whose header's EI_OSABI has the value ELFOSABI_GNU), that value should be interpreted as SHT_GNU_ATTRIBUTES.

Version-Release number of selected component (if applicable):
file-5.11-6 (what's now in Rawhide)

How reproducible:

Steps to Reproduce:
$ echo 'int main(int argc){return log10(argc);}' | gcc -x c -fPIC /dev/stdin -m32 -lm
/dev/stdin: In function 'main':
/dev/stdin:1:27: warning: incompatible implicit declaration of built-in function 'log10' [enabled by default]
$ file a.out 
a.out: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, with unknown capability 0x41000000 = 0xf676e75, with unknown capability 0x10000 = 0x70401, not stripped

Actual results:
As indicated.

Expected results:
Ditch the "unknown capability" stuff.

Additional info:

Comment 1 Petr Machata 2012-11-30 16:55:07 UTC
And the -fPIC is unnecessary.

Comment 2 Jan Kaluža 2012-12-04 06:34:55 UTC
Please could you attach that binary if you still have access to some PowerPC machine?

Comment 4 Petr Machata 2012-12-04 11:05:11 UTC
The RPM can be download from here: https://brewweb.devel.redhat.com/buildinfo?buildID=229838
Apologies, I didn't realize the RPM link on that page that I linked wouldn't allow downloading.

Comment 5 Jan Kaluža 2012-12-05 08:53:22 UTC
Thanks... It looks like it needs lot of changes in File's readelf.c code to support attributes properly. Turning this off for architectures where File currently does not support attributes would be easy, but implementing it for all archs is basically rewrite of big part of readelf.c. I will ask upstream what he thinks about it. Personally I think File should use some library to read elf files, but upstream is against external dependencies...

Comment 6 Petr Machata 2012-12-05 11:40:18 UTC
The library wouldn't tell you anything more than what is available now anyway.

The problem is in comparing section types that lie in OS-specific range. In binaries whose EI_OSABI has the value ELFOSABI_GNU, that particular value (0x6ffffff5) shouldn't be considered as SHT_SUNW_cap, but as SHT_GNU_ATTRIBUTES.  It look like the information about EI_OSABI needs to be propagated from the part that parses Elf header to the part that takes care of parsing capabilities.

Comment 7 Jan Kaluža 2012-12-05 12:53:41 UTC
Right, but then you have to start checking what's the data encoding (ELFDATA2MSB vs. ELFDATA2LSB) which is not handled in File right now and also rewrite whole attributes parsing logic to handle PPC and s390 attributes (which have different semantics). I'm not saying it's not possible, but I think it basically means rewrite of readelf.c.

I will ask upstream what he thinks about it and if it wouldn't be better to use external library to do this instead of reinventing ELF parsing again.

As a workaround I can patch File to not display attributes for PPC and S390 ELF binaries. It would not be a regression, because current state is broken anyway.

Comment 8 Jan Kaluža 2012-12-13 07:54:39 UTC
Upstream thinks the proper way to fix it is to disable capabilities on currently unsupported e_machines. I've sent the patch upstream and will fix this bug once he accepts it.

Comment 9 Fedora End Of Life 2013-01-16 22:49:31 UTC
This message is a reminder that Fedora 16 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 16. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '16'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 16's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 16 is end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" and open it against that version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 

Note You need to log in before you can comment on or make changes to this bug.