Ian Lance Taylor
Mon Jun 7 03:45:00 GMT 2010
fearyourself <email@example.com> writes:
> If I declare a new section bss_bigsegment, than it isn't seen as a
> common section by anybody.
> Therefore, two different files might have these segments and the
> linker will set the same base address for each file.
I'm not sure what you mean by "set the same base address", but the
linker should not merge two sections from different files together;
they should have different addresses in the generated file.
> However, if I declare in the elf_backend_section_flags hook that this
> section is also a SEC_IS_COMMON, then I get the right addressing.
What object file format are you using?
I gather that you actually want a common section here. Note that BSS
sections are not normally common sections. A BSS section represents
zero-initialized data. A common section is used to implement cases
where the same definition may appear multiple times in different
object files, and the linker merges them together rather than giving a
multiple definition error.
> However, I then get a weird error when I do:
> gcc hello.c -lc -lc I get multiple declarations of variables in
> bss_bigsegment that were defined by newlib.
This suggests that you have non-common symbols defined in a section
that you want to treat as common. Unless you are working with Fortran
programs, this is sufficiently odd that I think you need to explain
further what you are trying to do.
More information about the Binutils