libfdt: overlay: ensure that existing phandles are not overwritten

A phandle in an overlay is not supposed to overwrite a phandle that
already exists in the base dtb as this breaks references to the
respective node in the base.

So add another iteration over the fdto that checks for such overwrites
and fixes the fdto phandle's value to match the fdt's.

A test is added that checks that newly added phandles and existing
phandles work as expected.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Message-ID: <20240225175422.156393-2-u.kleine-koenig@pengutronix.de>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Uwe Kleine-König 2024-02-25 18:54:23 +01:00 committed by David Gibson
parent b0aacd0a77
commit 1fad065080
4 changed files with 334 additions and 0 deletions

View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 Uwe Kleine-König
*
* SPDX-License-Identifier: GPL-2.0+
*/
/dts-v1/;
/ {
node_a: a {
value = <17>;
};
node_b: b {
a = <&node_a>;
};
node_d: d {
b = <&node_b>;
};
};