Bug 1296211

Summary: SLOF cannot be built on 64bit little endian host
Product: Red Hat Enterprise Linux 7 Reporter: Laurent Vivier <lvivier>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Michael Petlan <mpetlan>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.2CC: mcermak, mpetlan, mpolacek, ohudlick
Target Milestone: rc   
Target Release: ---   
Hardware: ppc64le   
OS: Linux   
Whiteboard:
Fixed In Version: gcc-4.8.5-6.el7 Doc Type: No Doc Update
Doc Text:
undefined
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-04 06:27:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Laurent Vivier 2016-01-06 15:41:48 UTC
Description of problem:

SLOF is always built as a big endian target. To be built on a little endian host, SLOF makefile adds "-m64 -mbig" to gcc flags.

But the build fails on the link edition:

 ====== Building slof ======
make -C slof BOARD=qemu PLATFORM= FLAG="-DRTAS_NVRAM -DBROKEN_SC1 -DDHCPARCH=0x0C " TARG=ppc64 RELEASE=-DRELEASE=\"\\\"git-749c50b84b83a9b9\\\"\"
make[2]: Entering directory `/home/lvivier/SLOF/board-qemu/slof'
gcc -m64 -mbig -mabi=elfv1 -T/home/lvivier/SLOF/slof/OF.lds /home/lvivier/SLOF/slof/ofw.o version.o paflof.o helpers.o allocator.o \
/home/lvivier/SLOF/slof/entry.o romfs.o OF.o nvramlog.o /home/lvivier/SLOF/board-qemu/llfw/board_io.o \
/home/lvivier/SLOF/board-qemu/llfw/io_generic_lib.o -static -nostdlib -Wl,-q,-n /home/lvivier/SLOF/lib/libbootmsg.a /home/lvivier/SLOF/lib/libelf.a /home/lvivier/SLOF/lib/libhvcall.a /home/lvivier/SLOF/lib/libvirtio.a /home/lvivier/SLOF/lib/libusb.a /home/lvivier/SLOF/lib/libnvram.a /home/lvivier/SLOF/lib/libveth.a /home/lvivier/SLOF/lib/libe1k.a /home/lvivier/SLOF/lib/libc.a -o paflof
/home/lvivier/SLOF/slof/ofw.o:(.slof.loader+0x5c): undefined reference to `.patch_broken_sc1'

$ file /home/lvivier/SLOF/slof/ofw.o
/home/lvivier/SLOF/slof/ofw.o: ELF 64-bit MSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), not stripped

patch_broken_sc1 is in libhvcall:
$ nm lib/libhvcall/brokensc1.o|grep patch
0000000000000000 D patch_broken_sc1
$ file lib/libhvcall/brokensc1.o
lib/libhvcall/brokensc1.o: ELF 64-bit MSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), not stripped

Version-Release number of selected component (if applicable):

gcc-4.8.5-4.el7.ppc64le
binutils-2.23.52.0.1-55.el7.ppc64le

How reproducible:

100%

Steps to Reproduce:
1. git clone git://git.qemu-project.org/SLOF.git
2. cd SLOF
3. make V=2 qemu


Actual results:

Error: undefined reference to `.patch_broken_sc1'

Expected results:

Build slof without error.

Additional info:

It seems that "gcc" adds "--oformat elf32-powerpc" in case of "-mbig" even if the target is 64bit:

    *link_target:
    %{mlittle|mlittle-endian:;mbig|mbig-endian: --oformat elf32-powerpc;mcall-i960-old:;:}

If we remove the "-mbig" from the command line, all works fine as ld will use for output format the same as the input format (elf64-powerpc).

This can be related to BZ1279172, and this patch should fix this one too:
https://bugzilla.redhat.com/attachment.cgi?id=1091247

Comment 2 Jakub Jelinek 2016-05-03 16:31:49 UTC
This stuff got removed in http://gcc.gnu.org/r227397
and has been backported to 5 branch in r228089.

Comment 4 Michael Petlan 2016-07-25 09:51:11 UTC
test fails with gcc-4.8.5-4.el7.ppc64le
test passes for gcc-4.8.5-9.el7.ppc64le

VERIFIED

Comment 6 errata-xmlrpc 2016-11-04 06:27:27 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2433.html