Re: [PATCH] debug: fix BUILD_BUG_ON() for non-constant expressions

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ingo Molnar
Date: Monday, August 18, 2008 - 12:54 am

* Rusty Russell <rusty@rustcorp.com.au> wrote:


hm, have you tried it and do we get a severe enough link error about 
that? If the macro gets ignored by the compiler that's really a hard 
error - such things are essential safeguards of kernel sanity:

	/*
	 * Build-time sanity checks on the kernel image and module
	 * area mappings. (these are purely build-time and produce no code)
	 */
	BUILD_BUG_ON(MODULES_VADDR < KERNEL_IMAGE_START);
	BUILD_BUG_ON(MODULES_VADDR-KERNEL_IMAGE_START < KERNEL_IMAGE_SIZE);
	BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE);
	BUILD_BUG_ON((KERNEL_IMAGE_START & ~PMD_MASK) != 0);
	BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0);
	BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL));
	BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) ==
				(__START_KERNEL & PGDIR_MASK)));
	BUILD_BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <= MODULES_END);

( and propagating them into runtime failures not only increases bloat,
  it also makes failures harder to debug. These checks 'run' _early_. )

Link time warnings are easy enough to miss.

So unless there's a better way of doing it all at compile time (i'd 
really prefer that!) i'd prefer the link time error about botched 
BUILD_BUG_ON() conditions - as my commits introduce.

	Ingo
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] BUILD_BUG_ON sucks, Alexey Dobriyan, (Sat Aug 16, 3:09 am)
Re: [PATCH] BUILD_BUG_ON sucks, Rusty Russell, (Sat Aug 16, 3:55 am)
Re: [PATCH] BUILD_BUG_ON sucks, Andrew Morton, (Sat Aug 16, 10:46 am)
Re: [PATCH] BUILD_BUG_ON sucks, Linus Torvalds, (Sat Aug 16, 1:07 pm)
Re: [PATCH] BUILD_BUG_ON sucks, Theodore Tso, (Sun Aug 17, 5:19 am)
Re: [PATCH] BUILD_BUG_ON sucks, Andrew Morton, (Sun Aug 17, 9:33 am)
Re: [PATCH] debug: fix BUILD_BUG_ON() for non-constant exp ..., Ingo Molnar, (Mon Aug 18, 12:54 am)