Make it build on i686, though it's unclear it'll ever be necessary.

This commit is contained in:
Peter Jones 2012-06-21 10:55:08 -04:00
parent dccc1c90c3
commit ed349fc2d7
3 changed files with 165 additions and 3 deletions

View File

@ -0,0 +1,78 @@
From ec2cd81a6f275d14f8c3d13c94229a8cab0f343c Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 21 Jun 2012 09:58:29 -0400
Subject: [PATCH] Use uintptr_t instead of specificly sized types where
appropriate.
---
src/actions.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/actions.c b/src/actions.c
index 31fc66f..e60a13e 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -471,7 +471,7 @@ generate_digest(pesign_context *ctx, Pe *pe)
struct pe32_opt_hdr *pe32opthdr = NULL;
struct pe32plus_opt_hdr *pe64opthdr = NULL;
PK11Context *pk11ctx;
- uint64_t hashed_bytes = 0;
+ unsigned long hashed_bytes = 0;
int rc = -1;
if (!pe) {
@@ -512,13 +512,13 @@ generate_digest(pesign_context *ctx, Pe *pe)
case PE_K_PE_EXE: {
void *opthdr = pe_getopthdr(pe);
pe32opthdr = opthdr;
- hash_size = (uint64_t)&pe32opthdr->csum - (uint64_t)hash_base;
+ hash_size = (uintptr_t)&pe32opthdr->csum - (uintptr_t)hash_base;
break;
}
case PE_K_PE64_EXE: {
void *opthdr = pe_getopthdr(pe);
pe64opthdr = opthdr;
- hash_size = (uint64_t)&pe64opthdr->csum - (uint64_t)hash_base;
+ hash_size = (uintptr_t)&pe64opthdr->csum - (uintptr_t)hash_base;
break;
}
default:
@@ -538,7 +538,7 @@ generate_digest(pesign_context *ctx, Pe *pe)
if (rc < 0 || !dd)
goto error;
- hash_size = (uint64_t)&dd->certs - (uint64_t)hash_base;
+ hash_size = (uintptr_t)&dd->certs - (uintptr_t)hash_base;
PK11_DigestOp(pk11ctx, hash_base, hash_size);
/* 8. Skip over the crt dir
@@ -546,7 +546,7 @@ generate_digest(pesign_context *ctx, Pe *pe)
hash_base = &dd->base_relocations;
hash_size = (pe32opthdr ? pe32opthdr->header_size
: pe64opthdr->header_size) -
- ((uint64_t)&dd->base_relocations - (uint64_t)map);
+ ((uintptr_t)&dd->base_relocations - (uintptr_t)map);
PK11_DigestOp(pk11ctx, hash_base, hash_size);
/* 10. Set SUM_OF_BYTES_HASHED to the size of the header. */
@@ -566,7 +566,7 @@ generate_digest(pesign_context *ctx, Pe *pe)
sort_shdrs(shdrs, pehdr.sections - 1);
for (int i = 0; i < pehdr.sections; i++) {
- hash_base = (void *)((uint64_t)map + shdrs[i].data_addr);
+ hash_base = (void *)((uintptr_t)map + shdrs[i].data_addr);
hash_size = shdrs[i].raw_data_size;
PK11_DigestOp(pk11ctx, hash_base, hash_size);
@@ -574,7 +574,7 @@ generate_digest(pesign_context *ctx, Pe *pe)
}
if (map_size > hashed_bytes) {
- hash_base = (void *)((uint64_t)map + hashed_bytes);
+ hash_base = (void *)((uintptr_t)map + hashed_bytes);
hash_size = map_size - dd->certs.size - hashed_bytes;
PK11_DigestOp(pk11ctx, hash_base, hash_size);
}
--
1.7.10.2

View File

@ -0,0 +1,79 @@
From 020edc721159a7aee09bdaef54d22f11f40766d6 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 21 Jun 2012 10:16:25 -0400
Subject: [PATCH 3/3] Fix paths for 32-bit builds.
---
Make.defaults | 19 +++++++++----------
util/Makefile | 6 +++---
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/Make.defaults b/Make.defaults
index feda335..50b28b7 100644
--- a/Make.defaults
+++ b/Make.defaults
@@ -11,15 +11,14 @@ LDFLAGS = -nostdlib
CCLDFLAGS = -shared
INSTALL = install
# XXX this is broken
-LIBDIR = $(PREFIX)/lib64
-prefix = /usr/bin/
+bindir = /usr/bin/
-CC = $(prefix)gcc
-AS = $(prefix)as
-LD = $(prefix)ld.bfd
-AR = $(prefix)ar
-RANLIB = $(prefix)ranlib
-OBJCOPY = $(prefix)objcopy
+CC = $(bindir)gcc
+AS = $(bindir)as
+LD = $(bindir)ld.bfd
+AR = $(bindir)ar
+RANLIB = $(bindir)ranlib
+OBJCOPY = $(bindir)objcopy
ifeq ($(ARCH),ia64)
CFLAGS += -mfixed-range=f32-f127
@@ -27,17 +26,17 @@ ifeq ($(ARCH),ia64)
endif
ifeq ($(ARCH), ia32)
+ LIBDIR := $(PREFIX)/lib
ifeq ($(HOSTARCH), x86_64)
ARCH3264 := -m32
- LIBDIR := $(PREFIX)/lib
endif
endif
ifeq ($(ARCH), x86_64)
CFLAGS += -mno-red-zone
+ LIBDIR := $(PREFIX)/lib64
ifeq ($(HOSTARCH), ia32)
ARCH3264 := -m64
- LIBDIR := $(PREFIX)/lib64
endif
endif
diff --git a/util/Makefile b/util/Makefile
index 1dd4ca0..1cf782c 100644
--- a/util/Makefile
+++ b/util/Makefile
@@ -3,11 +3,11 @@ TOPDIR = $(SRCDIR)/..
include $(TOPDIR)/Make.defaults
-FORMAT=efi-app-x86_64
-LDFLAGS = -nostdlib -T /usr/lib64/gnuefi/elf_x86_64_efi.lds -shared -Bsymbolic /usr/lib64/gnuefi/crt0-efi-x86_64.o -L/usr/lib64/
+FORMAT=efi-app-$(HOSTARCH)
+LDFLAGS = -nostdlib -T $(LIBDIR)/gnuefi/elf_$(HOSTARCH)_efi.lds -shared -Bsymbolic $(LIBDIR)/gnuefi/crt0-efi-$(HOSTARCH).o -L$(LIBDIR)
LIBS=-lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name)
CCLDFLAGS =
-CFLAGS = -I/usr/include/efi/ -I/usr/include/efi/x86_64/ -I/usr/include/efi/protocol -fpic -fshort-wchar -fno-reorder-functions -fno-strict-aliasing -fno-merge-constants -mno-red-zone -Wimplicit-function-declaration
+CFLAGS = -I/usr/include/efi/ -I/usr/include/efi/$(HOSTARCH)/ -I/usr/include/efi/protocol -fpic -fshort-wchar -fno-reorder-functions -fno-strict-aliasing -fno-merge-constants -mno-red-zone -Wimplicit-function-declaration
TARGETS = setupsb.efi dumpsb.efi clearpk.efi
--
1.7.10.2

View File

@ -1,7 +1,7 @@
Summary: Signing utility for UEFI binaries Summary: Signing utility for UEFI binaries
Name: pesign Name: pesign
Version: 0.2 Version: 0.2
Release: 2%{?dist} Release: 3%{?dist}
Group: Development/System Group: Development/System
License: GPLv2 License: GPLv2
URL: https://github.com/vathpela/pesign URL: https://github.com/vathpela/pesign
@ -14,6 +14,8 @@ BuildRequires: git gnu-efi nspr nspr-devel nss nss-devel nss-util popt-devel
Requires: nspr nss nss-util popt Requires: nspr nss nss-util popt
Patch0: 0001-Fix-decl-of-pe_update-off_t-loff_t.patch Patch0: 0001-Fix-decl-of-pe_update-off_t-loff_t.patch
Patch1: 0002-Use-intptr_t-instead-of-specificly-sized-types-where.patch
Patch2: 0003-Fix-paths-for-32-bit-builds.patch
%description %description
This package contains the pesign utility for signing UEFI binaries as This package contains the pesign utility for signing UEFI binaries as
@ -29,7 +31,7 @@ git commit -a -q -m "%{version} baseline."
git am %{patches} </dev/null git am %{patches} </dev/null
%build %build
make make PREFIX=/usr %{?_smp_mflags}
%install %install
rm -rf %{buildroot} rm -rf %{buildroot}
@ -37,7 +39,7 @@ mkdir -p %{buildroot}/%{_libdir}
make PREFIX=%{_prefix} LIBDIR=%{_libdir} INSTALLROOT=%{buildroot} install make PREFIX=%{_prefix} LIBDIR=%{_libdir} INSTALLROOT=%{buildroot} install
# there's some stuff that's not really meant to be shipped yet # there's some stuff that's not really meant to be shipped yet
rm -rf %{buildroot}/boot %{buildroot}/usr/include %{buildroot}/usr/lib64 rm -rf %{buildroot}/boot %{buildroot}/usr/include %{buildroot}%{_libdir}
%clean %clean
rm -rf %{buildroot} rm -rf %{buildroot}
@ -50,6 +52,9 @@ rm -rf %{buildroot}
%attr(0700,root,root) /etc/pki/pesign %attr(0700,root,root) /etc/pki/pesign
%changelog %changelog
* Thu Jun 21 2012 Peter Jones <pjones@redhat.com> - 0.2-3
- Make it build on i686, though it's unclear it'll ever be necessary.
* Thu Jun 21 2012 Peter Jones <pjones@redhat.com> - 0.2-2 * Thu Jun 21 2012 Peter Jones <pjones@redhat.com> - 0.2-2
- Fix compile problem with f18's compiler. - Fix compile problem with f18's compiler.