This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gold bug combining .bss sections...


If, for example, we have a normal .bss in the final link with only a
necessary alignment of 4, and we also have a dynbss .bss with a copy
reloc needing an alignment of 8, gold outputs the final combined .bss
section with only an alignment of 4.

The copy reloc object can thus be not properly aligned, resulting
in SIGBUS errors on most types of RISC cpus.

This is causing several of the testcases for 64-bit sparc to fail.

In particular, two_file_shared_2_test, where the sequence of copy
relocs coming from two_file_shared_2.so is:

COPY: sym[v2] symsize[0x4] align[0x4]
COPY: sym[v3] symsize[0x4] align[0x4]
COPY: sym[v4] symsize[0xd] align[0x1]
COPY: sym[v5] symsize[0xd] align[0x1]
COPY: sym[t17data] symsize[0x28] align[0x8]

t17data is what ends up being not aligned properly because of this
bug.

This isn't likely to be noticed on i386 or x86_64 because
(non-MMX/SSE) unaligned memory accesses don't trap.

My best guess is that Output_segment::set_offset() needs some tweaks.

Although another notion I had is that perhaps when multiple copy
relocs get created, and the first copy reloc is of a smaller alignment
than later ones, this does not properly propagate into
Output_section->addralign_   I've copied the i386/x86_64 copy reloc
handling nearly line for line, and in particular I have:

      if (this->dynbss_ == NULL)
	{
	  this->dynbss_ = new Output_data_space(align);
	  layout->add_output_section_data(".bss",
					  elfcpp::SHT_NOBITS,
					  (elfcpp::SHF_ALLOC
					   | elfcpp::SHF_WRITE),
					  this->dynbss_);
	}

      Output_data_space* dynbss = this->dynbss_;

      if (align > dynbss->addralign())
	dynbss->set_space_alignment(align);

which should be taking care of this.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]