This commit is contained in:
Peter Robinson 2019-06-17 12:17:03 +01:00
parent 5b496731ae
commit cbaa4c59d9
3 changed files with 20 additions and 150 deletions

View File

@ -1,137 +0,0 @@
From 9619c8619c37b9aea98100bcc15c51a5642e877e Mon Sep 17 00:00:00 2001
From: Greg Kurz <groug@kaod.org>
Date: Thu, 30 Aug 2018 12:01:59 +0200
Subject: [PATCH 01/58] Kill bogus TYPE_BLOB marker type
Since commit 32b9c6130762 "Preserve datatype markers when emitting dts
format", we no longer try to guess the value type. Instead, we reuse
the type of the datatype markers when they are present, if the type
is either TYPE_UINT* or TYPE_STRING.
This causes 'dtc -I fs' to crash:
Starting program: /root/dtc -q -f -O dts -I fs /proc/device-tree
/dts-v1/;
/ {
Program received signal SIGSEGV, Segmentation fault.
__strlen_power8 () at ../sysdeps/powerpc/powerpc64/power8/strlen.S:47
47 ld r12,0(r4) /* Load doubleword from memory. */
(gdb) bt
#0 __strlen_power8 () at ../sysdeps/powerpc/powerpc64/power8/strlen.S:47
#1 0x00007ffff7de3d10 in __GI__IO_fputs (str=<optimized out>,
fp=<optimized out>) at iofputs.c:33
#2 0x000000001000c7a0 in write_propval (prop=0x100525e0,
f=0x7ffff7f718a0 <_IO_2_1_stdout_>) at treesource.c:245
The offending line is:
fprintf(f, "%s", delim_start[emit_type]);
where emit_type is TYPE_BLOB and:
static const char *delim_start[] = {
[TYPE_UINT8] = "[",
[TYPE_UINT16] = "/bits/ 16 <",
[TYPE_UINT32] = "<",
[TYPE_UINT64] = "/bits/ 64 <",
[TYPE_STRING] = "",
};
/* Data blobs */
enum markertype {
TYPE_NONE,
REF_PHANDLE,
REF_PATH,
LABEL,
TYPE_UINT8,
TYPE_UINT16,
TYPE_UINT32,
TYPE_UINT64,
TYPE_BLOB,
TYPE_STRING,
};
Because TYPE_BLOB < TYPE_STRING and delim_start[] is a static array,
delim_start[emit_type] is 0x0. The glibc usually prints out "(null)"
when one passes 0x0 to %s, but it seems to call fputs() internally if
the format is exactly "%s", hence the crash.
TYPE_BLOB basically means the data comes from a file and we don't know
its type. We don't care for the former, and the latter is TYPE_NONE.
So let's drop TYPE_BLOB completely and use TYPE_NONE instead when reading
the file. Then, try to guess the data type at emission time, like the
code already does for refs and labels.
Instead of adding yet another check for TYPE_NONE, an helper is introduced
to check if the data marker has type information, ie, >= TYPE_UINT8.
Fixes: 32b9c61307629ac76c6ac0bead6f926d579b3d2c
Suggested-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
data.c | 2 +-
dtc.h | 1 -
treesource.c | 9 +++++++--
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/data.c b/data.c
index accdfae..4a20414 100644
--- a/data.c
+++ b/data.c
@@ -95,7 +95,7 @@ struct data data_copy_file(FILE *f, size_t maxlen)
{
struct data d = empty_data;
- d = data_add_marker(d, TYPE_BLOB, NULL);
+ d = data_add_marker(d, TYPE_NONE, NULL);
while (!feof(f) && (d.len < maxlen)) {
size_t chunksize, ret;
diff --git a/dtc.h b/dtc.h
index 303c2a6..51c03ef 100644
--- a/dtc.h
+++ b/dtc.h
@@ -82,7 +82,6 @@ enum markertype {
TYPE_UINT16,
TYPE_UINT32,
TYPE_UINT64,
- TYPE_BLOB,
TYPE_STRING,
};
extern const char *markername(enum markertype markertype);
diff --git a/treesource.c b/treesource.c
index f99544d..53e6203 100644
--- a/treesource.c
+++ b/treesource.c
@@ -133,9 +133,14 @@ static void write_propval_int(FILE *f, const char *p, size_t len, size_t width)
}
}
+static bool has_data_type_information(struct marker *m)
+{
+ return m->type >= TYPE_UINT8;
+}
+
static struct marker *next_type_marker(struct marker *m)
{
- while (m && (m->type == LABEL || m->type == REF_PHANDLE || m->type == REF_PATH))
+ while (m && !has_data_type_information(m))
m = m->next;
return m;
}
@@ -225,7 +230,7 @@ static void write_propval(FILE *f, struct property *prop)
size_t chunk_len;
const char *p = &prop->val.val[m->offset];
- if (m->type < TYPE_UINT8)
+ if (!has_data_type_information(m))
continue;
chunk_len = type_marker_length(m);
--
2.20.1

View File

@ -1,17 +1,17 @@
Name: dtc
Version: 1.4.7
Release: 3%{?dist}
Version: 1.5.0
Release: 1%{?dist}
Summary: Device Tree Compiler
License: GPLv2+
URL: https://devicetree.org/
Source: https://ftp.kernel.org/pub/software/utils/%{name}/%{name}-%{version}.tar.xz
Patch1: use-tx-as-the-type-specifier-instead-of-zx.patch
Patch2: 0001-Kill-bogus-TYPE_BLOB-marker-type.patch
Source0: https://www.kernel.org/pub/software/utils/%{name}/%{name}-%{version}.tar.xz
#Patch1: use-tx-as-the-type-specifier-instead-of-zx.patch
BuildRequires: gcc make
BuildRequires: flex bison swig
BuildRequires: python2-devel python2-setuptools
#BuildRequires: python2-devel python2-setuptools
BuildRequires: python3-devel python3-setuptools
%description
Devicetree is a data structure for describing hardware. Rather than hard coding
@ -42,22 +42,26 @@ Requires: libfdt-devel = %{version}-%{release}
%description -n libfdt-static
This package provides the static library of libfdt
%package -n python2-libfdt
Summary: Python 2 bindings for device tree library
%package -n python3-libfdt
Summary: Python 3 bindings for device tree library
%{?python_provide:%python_provide python2-libfdt}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description -n python2-libfdt
%description -n python3-libfdt
This package provides python2 bindings for libfdt
%prep
%autosetup -p1
sed -i 's/python2/python3/' pylibfdt/setup.py
#sed -i 's/PREFIX/SETUP_PREFIX/' pylibfdt/Makefile.pylibfdt
%build
make %{?_smp_mflags} V=1 CC="gcc $RPM_OPT_FLAGS $RPM_LD_FLAGS"
%install
make install DESTDIR=$RPM_BUILD_ROOT SETUP_PREFIX=$RPM_BUILD_ROOT/usr PREFIX=/usr LIBDIR=%{_libdir}
#make install DESTDIR=$RPM_BUILD_ROOT SETUP_PREFIX=$RPM_BUILD_ROOT/usr PREFIX=/usr LIBDIR=%{_libdir}
PYTHON=python3 make install DESTDIR=$RPM_BUILD_ROOT PREFIX=$RPM_BUILD_ROOT/usr \
LIBDIR=%{_libdir} BINDIR=%{_bindir} INCLUDEDIR=%{_includedir} V=1
# we don't want or need ftdump and it conflicts with freetype-demos, so drop
# it (rhbz 797805)
@ -82,10 +86,13 @@ rm -f $RPM_BUILD_ROOT/%{_bindir}/ftdump
%{_libdir}/libfdt.so
%{_includedir}/*
%files -n python2-libfdt
%{python2_sitearch}/*
%files -n python3-libfdt
%{python3_sitearch}/*
%changelog
* Tue Mar 12 2019 Peter Robinson <pbrobinson@fedoraproject.org> 1.5.0-1
- New dtc 1.5.0 release
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.7-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

View File

@ -1 +1 @@
SHA512 (dtc-1.4.7.tar.xz) = 01e0c88aee154d8ce8a5b84a299c98d12df9698e5eff572409e5e912236028532309fd21ca6a146dffef859c665d476bbbe13c371c621c1dee4abe546e5e6ebf
SHA512 (dtc-1.5.0.tar.xz) = fd1e692a1b7bf7987f921ad17d9be6719f7b3aa7915873b45fa86f4ecb1398a0a62cdf53c1fddf98a0f7fed9bf34a79f684018bd01a2b5e88746b50879bf7102