Skip to content

Commit

Permalink
powerpc/iseries: Remove compiler version dependent hack
Browse files Browse the repository at this point in the history
The creation of the flattened device tree depended on the compiler
putting the constant strings for an object in a section with a
particular name.  This was changed with recent compilers.  Do this
explicitly instead.

Without this patch, iseries kernels may silently not boot when built with
some compilers.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Stephen Rothwell authored and Benjamin Herrenschmidt committed Oct 27, 2009
1 parent 7abb840 commit 171fb12
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 42 deletions.
11 changes: 1 addition & 10 deletions arch/powerpc/platforms/iseries/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
EXTRA_CFLAGS += -mno-minimal-toc

extra-y += dt.o

obj-y += exception.o
obj-y += hvlog.o hvlpconfig.o lpardata.o setup.o dt_mod.o mf.o lpevents.o \
obj-y += hvlog.o hvlpconfig.o lpardata.o setup.o dt.o mf.o lpevents.o \
hvcall.o proc.o htab.o iommu.o misc.o irq.o
obj-$(CONFIG_PCI) += pci.o
obj-$(CONFIG_SMP) += smp.o
obj-$(CONFIG_VIOPATH) += viopath.o vio.o
obj-$(CONFIG_MODULES) += ksyms.o

quiet_cmd_dt_strings = DT_STR $@
cmd_dt_strings = $(OBJCOPY) --rename-section .rodata.str1.8=.dt_strings \
$< $@

$(obj)/dt_mod.o: $(obj)/dt.o
$(call if_changed,dt_strings)
56 changes: 24 additions & 32 deletions arch/powerpc/platforms/iseries/dt.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,16 @@

/*
* These are created by the linker script at the start and end
* of the section containing all the strings from this file.
* of the section containing all the strings marked with the DS macro.
*/
extern char __dt_strings_start[];
extern char __dt_strings_end[];

#define DS(s) ({ \
static const char __s[] __attribute__((section(".dt_strings"))) = s; \
__s; \
})

struct iseries_flat_dt {
struct boot_param_header header;
u64 reserve_map[2];
Expand All @@ -64,9 +69,8 @@ struct iseries_flat_dt {
static void * __initdata dt_data;

/*
* Putting these strings here keeps them out of the section
* that we rename to .dt_strings using objcopy and capture
* for the strings blob of the flattened device tree.
* Putting these strings here keeps them out of the .dt_strings section
* that we capture for the strings blob of the flattened device tree.
*/
static char __initdata device_type_cpu[] = "cpu";
static char __initdata device_type_memory[] = "memory";
Expand Down Expand Up @@ -173,7 +177,7 @@ static void __init dt_start_node(struct iseries_flat_dt *dt, const char *name)

#define dt_end_node(dt) dt_push_u32(dt, OF_DT_END_NODE)

static void __init dt_prop(struct iseries_flat_dt *dt, const char *name,
static void __init __dt_prop(struct iseries_flat_dt *dt, const char *name,
const void *data, int len)
{
unsigned long offset;
Expand All @@ -191,44 +195,32 @@ static void __init dt_prop(struct iseries_flat_dt *dt, const char *name,
/* The actual data. */
dt_push_bytes(dt, data, len);
}
#define dt_prop(dt, name, data, len) __dt_prop((dt), DS(name), (data), (len))

static void __init dt_prop_str(struct iseries_flat_dt *dt, const char *name,
const char *data)
{
dt_prop(dt, name, data, strlen(data) + 1); /* + 1 for NULL */
}
#define dt_prop_str(dt, name, data) \
dt_prop((dt), name, (data), strlen((data)) + 1); /* + 1 for NULL */

static void __init dt_prop_u32(struct iseries_flat_dt *dt, const char *name,
static void __init __dt_prop_u32(struct iseries_flat_dt *dt, const char *name,
u32 data)
{
dt_prop(dt, name, &data, sizeof(u32));
__dt_prop(dt, name, &data, sizeof(u32));
}
#define dt_prop_u32(dt, name, data) __dt_prop_u32((dt), DS(name), (data))

static void __init __maybe_unused dt_prop_u64(struct iseries_flat_dt *dt,
const char *name,
u64 data)
static void __init __maybe_unused __dt_prop_u64(struct iseries_flat_dt *dt,
const char *name, u64 data)
{
dt_prop(dt, name, &data, sizeof(u64));
__dt_prop(dt, name, &data, sizeof(u64));
}
#define dt_prop_u64(dt, name, data) __dt_prop_u64((dt), DS(name), (data))

static void __init dt_prop_u64_list(struct iseries_flat_dt *dt,
const char *name, u64 *data, int n)
{
dt_prop(dt, name, data, sizeof(u64) * n);
}
#define dt_prop_u64_list(dt, name, data, n) \
dt_prop((dt), name, (data), sizeof(u64) * (n))

static void __init dt_prop_u32_list(struct iseries_flat_dt *dt,
const char *name, u32 *data, int n)
{
dt_prop(dt, name, data, sizeof(u32) * n);
}
#define dt_prop_u32_list(dt, name, data, n) \
dt_prop((dt), name, (data), sizeof(u32) * (n))

#ifdef notyet
static void __init dt_prop_empty(struct iseries_flat_dt *dt, const char *name)
{
dt_prop(dt, name, NULL, 0);
}
#endif
#define dt_prop_empty(dt, name) dt_prop((dt), name, NULL, 0)

static void __init dt_cpus(struct iseries_flat_dt *dt)
{
Expand Down

0 comments on commit 171fb12

Please sign in to comment.