Re: gdb.mi/mi-cli.exp failures

Daniel Jacobowitz
2003-04-02T17:28:28Z

On Wed, Apr 02, 2003 at 09:21:13AM -0800, Ian Lance Taylor wrote:
> Nick Clifton <nickc@redhat.com> writes:
>
> > > It's doing this:
> > > sinfo->stabstr = bfd_make_section_anyway (abfd, ".stabstr");
> > > which doesn't make much sense to me; there's _already_ a section named
> > > .stabstr in the executable, why not use that one?
> >
> > Hmm, agreed - this probably ought to be a call to
> > bfd_get_section_by_name(). And if that fails then the code should try
> > to find the output bfd and create the section there. (Either that or
> > else return a failure result. Can you have a .stabs section without a
> > .stabsstr section ?)
>
> I created a .stabstr section in the input file because I needed to
> have a section in an input file which the linker script could put into
> the output file correctly. This is not the only place where this
> trick is used.
>
> Using an existing .stabstr section would have to be handled carefully.
> The code would have to extract the information, and arrange to replace
> it in the output file. This might not be too hard.
>
> Creating the .stabstr section in the output BFD doesn't work, because
> it won't let the linker script function properly.

Well, do you have another suggestion for how to approach this? We're
not actually linking; but I need to get the symbols from the input file
into a symbol table with forged offsets in order to apply relocations
against them.

> > > Can I not rely on section_count remaining stable for an input BFD?
> >
> > I think that you ought to be able to rely on this.
>
> Well, I'm afraid that you will have to deal with a number of other
> cases if you want to avoid adding sections to input files. Take a
> look at elf_link_create_dynamic_sections().

In any case I can remove the assumption; it's not hard. I assume that
if I save pointers to the sections present before calling
elf_link_add_object_symbols, that they'll still be valid when it
returns?

--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer