This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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: set sysroot command on AIX has no effect.


Sangamesh Mallayya wrote:

>> Well, of course, you have to check for NULL.  What I'm suggesting is to
>> use something along the lines of:
>> 
>>   found_pathname = solib_find (filename, &found_file);
>>   if (found_pathname == NULL)
>>     // error handling
>>   archive_bfd = solib_bfd_fopen (found_pathname, found_file);
>
>Yes, i did try these steps. But this won't set the sysroot path as we 
>intend to.
>The final object filename we want is the one returned from solib_find, 
>which is a sysroot prefixed pathname.
>After solib_bfd_fopen call we can't refer to found_pathname as it's been 
>freed in solib_bfd_fopen at the end, and assertion failure later.

Well, if you want to reuse the found_pathname, you'll just have to
duplicate it (there's already a call to xstrdup later in the function,
you may have to move it earlier).

>> > +   pathname = solib_find (filename, &found_file);
>> > +   if (pathname == NULL)
>> > +       perror_with_name (filename);
>> >     archive_bfd = gdb_bfd_open (filename, gnutarget, -1);
>> >     if (archive_bfd == NULL)
>> >       {
>> 
>> This has a number of problems:
>> - you still use gdb_bfd_open with filename, which means it still won't
>>   find the file  (I assume you meant to use pathname?)
>
>pathname we get is something like "/usr/lib/libc.a(shr.o)", Offcourse 
>their is no such file with this pathname in the system.
>So we set a filename as "/usr/lib/libc.a" after separating member name 
>from actual file and gdb_bfd_open does find the file and return it's bfd.
>Here if we pass the path returned from solib_find to gdb_bfd_open instead 
>of filename then no issue is seen.

My point was, the code as shown above does *not* pass the path returned
from solib_find to gdb_bfd_open!  The path returned from solib_find is
assigned to "pathname" (overriding the value pathname that was input to
the function), but then gdb_bfd_open is still called with "filename".

>I think, better we use found_pathname variable to store returned value 
>from solib_find instead of using existing pathname variable to avoid 
>confusion.
>And may assign object filename as "object_bfd->filename = xstrdup 
>(found_pathname);" ?

Agreed (see above).  However, note that this will *not* contain the
object name in parentheses.  For example, if you initially get a
pathname of:
  /usr/lib/libc.a(shr.o)
Then you separate out the filename into:
  /usr/lib/libc.a
Then you pass this to solib_find and get a full name including sysroot:
  /path/to/sysroot/usr/lib/libc.a
But what you probably want to use as name in the final solib object is:
  /path/to/sysroot/usr/lib/libc.a(shr.o)

My point was that in order to get this, you'll have to append the
"(shr.o)" back on to the result you got from solib_find.

>The only problem i think if we use solib_find without using 
>solib_bfd_fopen is found_file descriptor.
>Let me know your view.

Please do use the pair of solib_find / solib_bfd_fopen; they were
designed to be used with each other, that's why they have the
interface they do.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


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