------- Comment #6 from wilson at gcc dot gnu dot org  2005-11-01 06:38 -------
Short story...
Your kernel code is broken.  init functions go in .init.text, but init data
goes in .init.data, not .init.text.  See the
Documentation/Docbook/kernel-hacking.tmpl file in any recent kernel.

Long story...
The more we use ELF, the more important it is to get the details right.  One of
the details we did not get right in the beginning is section type info.  Given
something like
int __attribute__ ((section ("foo"))) bar () { }
int __attribute__ ((section ("foo"))) baz = 1;
An old compiler like gcc-2.95 will emit
        .section        bar,"ax",@progbits
but this is clearly wrong, because we have both code and writable data in the
same section, and that section is not marked writable.

Newer compiler versions check for this, and correctly emit an error when they
see section type conflicts like this, as we can't emit both writable data and
code into the same section.  So the error you are getting here is expected, and
correct.

This bug happens not to affect the kernel's use of section in this specific
case, so it worked by accident with older compiler versions.  It will not and
should not work with current compiler versions, and hence the current kernel
has support for separate init text and init data sections.

It might be useful if the attribute section syntax was extended so that people
can specify what kind of section they want, but I don't see any real advantage
to doing that.  You shouldn't be mixing data and code in the same section
anyways.

Ideally, you should be using a comdat group here, but we have no syntax for
that either.  I think that would be a more useful attribute section syntax
extension.
There is no need for it to solve this particular problem though.  You just need
to use the right sections in your code.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24585

Reply via email to