Hello, This patch is a prototype towards converting all the ad hoc code and various deprecated features used to implement relocations to using a target_so_ops vector instead. One of the nice side-effects is that we are able to get rid of nm-rs6000.h entirely. This is a fairly lengthy email, which I am not too happy about, because I think it's going to make it harder for anyone willing to take a look and comment. But I thought it was important to provide some general info on it too. The reason for posting the patch generate comments, but also to ask a couple of questions on topics open for discussion regarding missing pieces in the core part of GDB. I will ask these questions again at the next submission, when the patch is a little cleaner, if no decision is made with that patch. The interface to the relocation data is itself relatively simple, and documented through a combination of the PT_LDINFO request in the ptrace man page, and the ldr.h system include. Basically, the PT_LDINFO gives us access to a raw buffer which is an array of structures whose type is defined in ldr.h. One of the small difficulties came from a specificity of the AIX platform regarding shared libraries: What we view as shared libraries on, say, GNU/Linux, is an archive file. For instance, /lib/libc.a. The linker then searches inside the archive file for dynamic objects (Eg: shr.o) on which the program depends, and links it against those specific object files, not just the archive. We observe that through the use of ldd on a simple program: % ldd simple_main simple_main needs: /lib/libc.a(shr.o) /lib/libcrypt.a(shr.o) This means that the current model where an objfile is a filename doesn't work very well. In this case, it's a filename and a member name. This prototype tip-toes around the issue for now, to limit its scope. This is a relatively messy prototype, where I have not paid any attention to memory management or process separation (Eg: -tdep code calling -nat code). This is a big part of the next iteration for this patch. Some elements I would like to have some feedback on: - One important bit is something I alluded to above: a solib name is now no longer sufficient to identify it; we need the filename, which is usually an archive, and a member name (which may be NULL). Right now, I store a composite into the struct so_list->so_name field which follows the same convention as AIX's ldd: Eg. "/lib/lib.c(shr.o)". Some minor issues: - struct objfile's name is the name from the bfd, and thus Eg "shr.o"; any display of that name in the debugger output and warning/error messages is incomplete - the bfd_open target_so_ops method only takes a pathname for getting the bfd; but that's not sufficient. What the current does is just parse the pathname and split it into real pathname, and member name. Acceptable for a prototype, but perhaps we should consider passing a reference to the so_list object? - See also the FIXME in solib.c:solib_map_sections, which overwrites the so_name in the so_list struct. This of course overwrites the composite name. Two consequences: - "info sharedlibrary" does not show the composite name (missing piece of info) - the bfd_open hook is missing the composite name also, at least until the so_list is passed instead of just the pathname. Some of the options I have considered: - For the "info sharedlibrary" command, enhance the solib vector to provide a "so_name" function that, given a struct so_list, returns the solib's "print" name. solib-aix would access the lm_info to do so. Or rather than returning a string, with its usual memory management issues, would print it to a stream? - Stop encoding the archive-name+member-name into the so_list so_name. We need to be careful there, because even if we were able to print the solib name correct (as discussed above), I think we have some mechanism in the solib code that deals with duplicates using the so_name. Since it is very common for two archives to have members with the same name, we need to make sure that this identification mechanism keeps working. The so_name compositing helps achieving that. - Issue when printing the objfile name: This one is going to be messy, I think. I was thinking of defining the concept of an objfile's "print" name, which could work as follow: If the objfile's bfd has a my_archive, then it would be "name>(name>)"; otherwise, the usual "name>". I don't think we really need to address that issue, especially not right now. - xcoff_symfile_offsets was greatly simplified, and in fact could be entirely replaced by default_symfile_offsets, if it wasn't for some code which defaults some section indices in the objfile to zero even when the section actually does not exist. I could probably work with that because this seems to only affect the rodata sect index in practice, and that section does not exist on AIX (yet). But I think that's taking a chance. The code that does that was added a very long time ago, and was probably meant for ELF. For now, I've added code in xcoff_symfile_offsets to just call default_symfile_offsets followed by the undoing of the sect index zero'ing. Fine for now, but something we might want to look at eventually? Some questions I asked myself (with some answers): - Because of the dependency on the system ldr.h file, there is a temporary dependency of solib-aix on rs6000-nat, which we do not want, especially since rs6000-aix-tdep also depends on solib-aix (to get the TOC value in order to setup inferior function calls). I am planning on fixing this by adding a new xfer object. - The changes in rs6000-aix-tdep.c are adjustments to the new method towards getting the TOC value. It calls a function in solib-aix rather than relying on a hook setup by the -nat code. This means that it can also be made to work when configured as a cross debugger. - The new code in rs6000-nat is a little hard to read. It basically just gets the raw ld_info data from ptrace (PT_LDINFO), and transforms it into a structured VEC. This will likely change when integrated into the xfer_memory framework, but the idea will remain the same. - I am also planning on caching the ld_info data, to avoid re-fetching the data multiple times when not necessary. But I think that this will be the subject of a followup patch, to avoid mixing everything in the same bag. - xcoffsolib.[hc] is now gone, as it is redundant with the solib.c code; - We will need to update the ARI in order to forbid the macros finally deleted. Voila voila, -- Joel PS: The patch is against AdaCore's HEAD, which is off a fairly recent set of sources, but modified to contain AdaCore's changes too. This was simpler for me to allow for testing, and may not apply cleanly to current FSF HEAD. Sorry if that is the case.