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]

Re: [PATCH] _bfd_mips_elf_final_link: notify user about wrong .reginfo size


Hi Vlad,

> Target used was mipsel-sde-elf. It's triggered when the user-provided linker 
> script lacks .reginfo section. In order to fix it, the following line was 
> added to the linker script:
> 
>     .reginfo                 0 : { KEEP(*(.reginfo)) }

 Thank you for the explanation.  While I wasn't able to reproduce the 
assertion failure by just having no `.reginfo' section in a linker script 
(or having it explicitly removed with a /DISCARD/ clause) I was able to do 
so with input that has no `.reginfo' section and this linker script:

SECTIONS
{
  .reginfo : { foo = .; }
  /DISCARD/ : { *(*) }
}

and also with this linker script:

SECTIONS
{
  .reginfo : { *(.data) }
  /DISCARD/ : { *(*) }
}

and an oversize input `.data' section.  I will convert these examples to 
proper test suite cases.

 Also with the latter linker script and an undersized `.data' section a 
link failure happens with a cryptic:

ld: final link failed: Bad value

error message produced.  This is because `bfd_get_section_contents' fails 
in `_bfd_mips_elf_final_link' at elfxx-mips.c:14355, however we don't 
bother producing a more specific error message, one that would at least 
mention the name of the offending section.  I think this will have to be 
adressed too, with a separate change.

> Since the assertion itself wasn't very self-descriptive, I decided to 
> submit a patch for it. I'm not sure if this change needs a test.

 No assertion failure is allowed for any input, valid or not.  For invalid 
input a proper error message has to be printed instead.  Assertions are 
only allowed as internal consistency checks, essentially situations that 
are expected to never happen.  So your change is highly desirable as it 
improves the quality of error reporting.

> As far as I understand, the issue here is not the input section being
> wrong size (although this may happen too) but rather a total lack
> of such input section, which leads to a creation of zero-sized output
> section.

 I can trigger another assertion, in `_bfd_mips_elf_section_processing' at 
elfxx-mips.c:7105, which is where input sections are processed, either by 
assembling input as simple as:

	.section	.reginfo, "a"
	.word		0xdeadbeef

or by renaming a section to `.reginfo' with `objcopy'.  This will have to 
be addressed with a separate change (and respective test suite cases).

  Maciej


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