Fix gcc 8.1 build compat (bz #1653655)
This commit is contained in:
parent
2e5a794281
commit
8bc6b113ec
@ -0,0 +1,31 @@
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Wed, 18 Jul 2018 15:44:59 +0200
|
||||
Subject: [PATCH] make.rules: Compile SLOF with -fno-asynchronous-unwind-tables
|
||||
|
||||
With the new GCC 8, the asynchronous-unwind-tables are always enabled.
|
||||
We don't need this for SLOF, so disable them to save 32 kiB in the
|
||||
boot_rom.bin.
|
||||
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
||||
(cherry picked from commit 5cd96a5ba9782d6f1c2d53d02d5a265fbcae580b)
|
||||
---
|
||||
make.rules | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/make.rules b/make.rules
|
||||
index 3067314..acbc8ab 100644
|
||||
--- a/make.rules
|
||||
+++ b/make.rules
|
||||
@@ -73,8 +73,9 @@ RANLIB ?= $(CROSS)ranlib
|
||||
CPP ?= $(CROSS)cpp
|
||||
|
||||
WARNFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -Wformat-security
|
||||
-CFLAGS ?= -g -O2 -fno-builtin -ffreestanding -nostdinc -msoft-float -fno-strict-aliasing \
|
||||
- -mno-altivec -mabi=no-altivec -fno-stack-protector $(WARNFLAGS)
|
||||
+CFLAGS ?= -g -O2 -fno-builtin -ffreestanding -nostdinc -msoft-float \
|
||||
+ -fno-strict-aliasing -mno-altivec -mabi=no-altivec \
|
||||
+ -fno-stack-protector -fno-asynchronous-unwind-tables $(WARNFLAGS)
|
||||
|
||||
export CC AS LD CLEAN OBJCOPY OBJDUMP STRIP AR RANLIB CFLAGS
|
||||
|
111
0002-romfs-tools-Remove-superfluous-union-around-the-rom-.patch
Normal file
111
0002-romfs-tools-Remove-superfluous-union-around-the-rom-.patch
Normal file
@ -0,0 +1,111 @@
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Thu, 19 Jul 2018 14:46:24 +0200
|
||||
Subject: [PATCH] romfs/tools: Remove superfluous union around the rom header
|
||||
struct
|
||||
|
||||
Accessing the struct with memset and memcpy can also be done without the
|
||||
union wrapper. While we're at it, also remove the FLASHFS_HEADER_DATA_SIZE
|
||||
macre and use sizeof(stHeader) instead.
|
||||
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
||||
(cherry picked from commit d4443f17c956e77df7bb23b2d19462faae9f4b23)
|
||||
---
|
||||
include/calculatecrc.h | 1 -
|
||||
romfs/tools/create_crc.c | 29 +++++++++++++----------------
|
||||
2 files changed, 13 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/include/calculatecrc.h b/include/calculatecrc.h
|
||||
index a19a229..667ea81 100644
|
||||
--- a/include/calculatecrc.h
|
||||
+++ b/include/calculatecrc.h
|
||||
@@ -17,7 +17,6 @@
|
||||
#define FLASHFS_HEADER_SIZE_ADDR 0x08 // uint64_t position of total flash header size value
|
||||
|
||||
#define FLASHFS_ROMADDR 0x00 // uint64_t position of pointer to next file
|
||||
-#define FLASHFS_HEADER_DATA_SIZE 0x68 // 104 bytes of total header data size
|
||||
#define CRC_METHODE Ethernet_32 // define the CRC genarator (CRC 16 bit to 64 is supported)
|
||||
|
||||
//--- header format ---------------------------------
|
||||
diff --git a/romfs/tools/create_crc.c b/romfs/tools/create_crc.c
|
||||
index 5a76b9c..e354339 100644
|
||||
--- a/romfs/tools/create_crc.c
|
||||
+++ b/romfs/tools/create_crc.c
|
||||
@@ -10,6 +10,7 @@
|
||||
* IBM Corporation - initial implementation
|
||||
*****************************************************************************/
|
||||
|
||||
+#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -71,21 +72,18 @@ createHeaderImage(int notime)
|
||||
char dastr[16] = { 0, };
|
||||
unsigned long long da = 0;
|
||||
|
||||
- union {
|
||||
- unsigned char pcArray[FLASHFS_HEADER_DATA_SIZE];
|
||||
- struct stH stHeader;
|
||||
- } uHeader;
|
||||
+ struct stH stHeader;
|
||||
|
||||
/* initialize Header */
|
||||
- memset(uHeader.pcArray, 0x00, FLASHFS_HEADER_DATA_SIZE);
|
||||
+ memset(&stHeader, 0x00, sizeof(stHeader));
|
||||
|
||||
/* read driver info */
|
||||
if (NULL != (pcVersion = getenv("DRIVER_NAME"))) {
|
||||
- strncpy(uHeader.stHeader.version, pcVersion, 16);
|
||||
+ strncpy(stHeader.version, pcVersion, 16);
|
||||
} else if (NULL != (pcVersion = getenv("USER"))) {
|
||||
- strncpy(uHeader.stHeader.version, pcVersion, 16);
|
||||
+ strncpy(stHeader.version, pcVersion, 16);
|
||||
} else if (pcVersion == NULL) {
|
||||
- strncpy(uHeader.stHeader.version, "No known user!", 16);
|
||||
+ strncpy(stHeader.version, "No known user!", 16);
|
||||
}
|
||||
|
||||
if (!notime) {
|
||||
@@ -104,18 +102,18 @@ createHeaderImage(int notime)
|
||||
}
|
||||
da = cpu_to_be64(strtoll(dastr, NULL, 16));
|
||||
}
|
||||
- memcpy(uHeader.stHeader.date, &da, 8);
|
||||
+ memcpy(stHeader.date, &da, 8);
|
||||
|
||||
/* write Magic value into data stream */
|
||||
- strncpy(uHeader.stHeader.magic, FLASHFS_MAGIC, 8);
|
||||
+ strncpy(stHeader.magic, FLASHFS_MAGIC, 8);
|
||||
/* write platform name into data stream */
|
||||
- strcpy(uHeader.stHeader.platform_name, FLASHFS_PLATFORM_MAGIC);
|
||||
+ strcpy(stHeader.platform_name, FLASHFS_PLATFORM_MAGIC);
|
||||
/* write platform revision into data stream */
|
||||
- strcpy(uHeader.stHeader.platform_revision, FLASHFS_PLATFORM_REVISION);
|
||||
+ strcpy(stHeader.platform_revision, FLASHFS_PLATFORM_REVISION);
|
||||
|
||||
|
||||
/* fill end of file info (8 bytes of FF) into data stream */
|
||||
- uHeader.stHeader.ui64FileEnd = -1;
|
||||
+ stHeader.ui64FileEnd = -1;
|
||||
|
||||
/* read address of next file and address of header date, both are 64 bit values */
|
||||
ui64RomAddr = 0;
|
||||
@@ -129,7 +127,7 @@ createHeaderImage(int notime)
|
||||
|
||||
/* calculate final flash-header-size and flash-file-size */
|
||||
/* calculate end addr of header */
|
||||
- ui64globalHeaderSize = (uint32_t) ui64DataAddr + (uint32_t) FLASHFS_HEADER_DATA_SIZE;
|
||||
+ ui64globalHeaderSize = (uint32_t) ui64DataAddr + sizeof(stHeader);
|
||||
/* cut 64 bit to place CRC for File-End */
|
||||
ui64globalHeaderSize -= 8;
|
||||
/* add 64 bit to place CRC behind File-End */
|
||||
@@ -143,8 +141,7 @@ createHeaderImage(int notime)
|
||||
/* fill free space in Header with zeros */
|
||||
memset(&pucFileStream[ui64DataAddr], 0, (ui64RomAddr - ui64DataAddr));
|
||||
/* place data to header */
|
||||
- memcpy(&pucFileStream[ui64DataAddr], uHeader.pcArray,
|
||||
- FLASHFS_HEADER_DATA_SIZE);
|
||||
+ memcpy(&pucFileStream[ui64DataAddr], &stHeader, sizeof(stHeader));
|
||||
|
||||
/* insert header length into data stream */
|
||||
*(uint64_t *) (pucFileStream + FLASHFS_HEADER_SIZE_ADDR) =
|
@ -0,0 +1,66 @@
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Thu, 19 Jul 2018 14:46:25 +0200
|
||||
Subject: [PATCH] romfs/tools: Silence GCC 8.1 compiler warning with
|
||||
FLASHFS_MAGIC
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
GCC 8.1 introduce some new warnings which affect create_crc.c. One of
|
||||
them is:
|
||||
|
||||
create_crc.c: In function ‘createHeaderImage’:
|
||||
create_crc.c:110:2: warning: ‘strncpy’ output truncated before terminating nul
|
||||
copying 8 bytes from a string of the same length [-Wstringop-truncation]
|
||||
strncpy(uHeader.stHeader.magic, FLASHFS_MAGIC, 8);
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Initialize the header struct statically here instead to silence the warning.
|
||||
|
||||
Suggested-by: Segher Boessenkool <segher@kernel.crashing.org>
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
||||
(cherry picked from commit 49482e06ea74652a70a8cd067b852cc142021c03)
|
||||
---
|
||||
romfs/tools/create_crc.c | 21 ++++++---------------
|
||||
1 file changed, 6 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/romfs/tools/create_crc.c b/romfs/tools/create_crc.c
|
||||
index e354339..475b184 100644
|
||||
--- a/romfs/tools/create_crc.c
|
||||
+++ b/romfs/tools/create_crc.c
|
||||
@@ -72,10 +72,12 @@ createHeaderImage(int notime)
|
||||
char dastr[16] = { 0, };
|
||||
unsigned long long da = 0;
|
||||
|
||||
- struct stH stHeader;
|
||||
-
|
||||
- /* initialize Header */
|
||||
- memset(&stHeader, 0x00, sizeof(stHeader));
|
||||
+ struct stH stHeader = {
|
||||
+ .magic = FLASHFS_MAGIC,
|
||||
+ .platform_name = FLASHFS_PLATFORM_MAGIC,
|
||||
+ .platform_revision = FLASHFS_PLATFORM_REVISION,
|
||||
+ .ui64FileEnd = -1,
|
||||
+ };
|
||||
|
||||
/* read driver info */
|
||||
if (NULL != (pcVersion = getenv("DRIVER_NAME"))) {
|
||||
@@ -104,17 +106,6 @@ createHeaderImage(int notime)
|
||||
}
|
||||
memcpy(stHeader.date, &da, 8);
|
||||
|
||||
- /* write Magic value into data stream */
|
||||
- strncpy(stHeader.magic, FLASHFS_MAGIC, 8);
|
||||
- /* write platform name into data stream */
|
||||
- strcpy(stHeader.platform_name, FLASHFS_PLATFORM_MAGIC);
|
||||
- /* write platform revision into data stream */
|
||||
- strcpy(stHeader.platform_revision, FLASHFS_PLATFORM_REVISION);
|
||||
-
|
||||
-
|
||||
- /* fill end of file info (8 bytes of FF) into data stream */
|
||||
- stHeader.ui64FileEnd = -1;
|
||||
-
|
||||
/* read address of next file and address of header date, both are 64 bit values */
|
||||
ui64RomAddr = 0;
|
||||
ui64DataAddr = 0;
|
@ -0,0 +1,64 @@
|
||||
From: Thomas Huth <thuth@redhat.com>
|
||||
Date: Mon, 23 Jul 2018 15:19:44 +0200
|
||||
Subject: [PATCH] romfs/tools: Silence more compiler warnings with GCC 8.1
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
GCC 8 complains about the following usages of strncpy, too:
|
||||
|
||||
create_crc.c:86:3: warning: ‘strncpy’ specified bound 16 equals destination
|
||||
size [-Wstringop-truncation]
|
||||
strncpy(uHeader.stHeader.version, pcVersion, 16);
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
create_crc.c:84:3: warning: ‘strncpy’ specified bound 16 equals destination
|
||||
size [-Wstringop-truncation]
|
||||
strncpy(uHeader.stHeader.version, pcVersion, 16);
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Let's work around the issue by using memcpy instead.
|
||||
|
||||
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
||||
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
||||
(cherry picked from commit d8a9354c2a351360da438826c95cf78efcaaf1b0)
|
||||
---
|
||||
romfs/tools/create_crc.c | 19 ++++++++++++-------
|
||||
1 file changed, 12 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/romfs/tools/create_crc.c b/romfs/tools/create_crc.c
|
||||
index 475b184..abc373b 100644
|
||||
--- a/romfs/tools/create_crc.c
|
||||
+++ b/romfs/tools/create_crc.c
|
||||
@@ -32,6 +32,11 @@ static uint64_t ui64globalHeaderSize = 0;
|
||||
/* flag to filter detect the header in buildDataStream() */
|
||||
static int iglobalHeaderFlag = 1;
|
||||
|
||||
+static size_t min(size_t a, size_t b)
|
||||
+{
|
||||
+ return a < b ? a : b;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* Build the file image and store it as Data Stream of bytes
|
||||
* calculate a first CRC for the first file and
|
||||
@@ -80,13 +85,13 @@ createHeaderImage(int notime)
|
||||
};
|
||||
|
||||
/* read driver info */
|
||||
- if (NULL != (pcVersion = getenv("DRIVER_NAME"))) {
|
||||
- strncpy(stHeader.version, pcVersion, 16);
|
||||
- } else if (NULL != (pcVersion = getenv("USER"))) {
|
||||
- strncpy(stHeader.version, pcVersion, 16);
|
||||
- } else if (pcVersion == NULL) {
|
||||
- strncpy(stHeader.version, "No known user!", 16);
|
||||
- }
|
||||
+ pcVersion = getenv("DRIVER_NAME");
|
||||
+ if (!pcVersion)
|
||||
+ pcVersion = getenv("USER");
|
||||
+ if (!pcVersion)
|
||||
+ pcVersion = "unknown";
|
||||
+ memcpy(stHeader.version, pcVersion,
|
||||
+ min(strlen(pcVersion), sizeof(stHeader.version)));
|
||||
|
||||
if (!notime) {
|
||||
/* read time and write it into data stream */
|
11
SLOF.spec
11
SLOF.spec
@ -11,7 +11,7 @@
|
||||
|
||||
Name: SLOF
|
||||
Version: 0.1.git%{gittagdate}
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Summary: Slimline Open Firmware
|
||||
|
||||
License: BSD
|
||||
@ -26,6 +26,12 @@ URL: http://www.openfirmware.info/SLOF
|
||||
# --prefix=SLOF-{gittagdate}/ {gittag}
|
||||
Source0: SLOF-%{gittagdate}.tar.gz
|
||||
|
||||
# Fix gcc 8.1 build compat (bz #1653655)
|
||||
Patch0001: 0001-make.rules-Compile-SLOF-with-fno-asynchronous-unwind.patch
|
||||
Patch0002: 0002-romfs-tools-Remove-superfluous-union-around-the-rom-.patch
|
||||
Patch0003: 0003-romfs-tools-Silence-GCC-8.1-compiler-warning-with-FL.patch
|
||||
Patch0004: 0004-romfs-tools-Silence-more-compiler-warnings-with-GCC-.patch
|
||||
|
||||
|
||||
%if 0%{?cross:1}
|
||||
BuildArch: noarch
|
||||
@ -75,6 +81,9 @@ cp -a boot_rom.bin %{buildroot}%{_datadir}/qemu/slof.bin
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Dec 12 2018 Cole Robinson <crobinso@redhat.com> - 0.1.git20180702-2
|
||||
- Fix gcc 8.1 build compat (bz #1653655)
|
||||
|
||||
* Thu Nov 15 2018 Cole Robinson <crobinso@redhat.com> - 0.1.git20180702-1
|
||||
- Update to SLOF 20180702 for qemu-3.1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user