gary is currently certified at Master level.

Name: Gary Benson
Member since: 2001-05-31 00:39:54
Last Login: 2012-10-24 12:18:42

FOAF RDF Share This

Homepage: http://gbenson.net/

Notes:

I work for Red Hat.

Projects

Articles Posted by gary

Recent blog entries by gary

Syndication: RSS 2.0

Run-time linker interface

If you’re debugging an application that loads thousands of shared libraries then be sure to read the LinkerInterface page on the GDB wiki.

Syndicated 2013-10-25 15:52:14 from gbenson.net

r_debug

I’ve been trying to figure out how to get information about libraries loaded with dlmopen out of glibc‘s runtime linker and into GDB.

The current interface uses a structure called r_debug that’s defined in link.h. If the executable’s dynamic section has a DT_DEBUG element, the runtime linker sets that element’s value to the address where this structure can be found. I tried to discover where this interface originated, but I didn’t get very far. The only mention of it I found anywhere in any standard is in the System V Application Binary Interface, where it says:

If an object file participates in dynamic linking, its program header table will have an element of type PT_DYNAMIC. This “segment” contains the .dynamic section. A special symbol, _DYNAMIC, labels the section…

and later:

DT_DEBUG
This member is used for debugging. Its contents are not specified for the ABI; programs that access this entry are not ABI-conforming.

No help there then. In glibc, r_debug looks like this:

struct r_debug
{
  int r_version;              /* Version number for this protocol.  */

  struct link_map *r_map;     /* Head of the chain of loaded objects.  */

  /* This is the address of a function internal to the run-time linker,
     that will always be called when the linker begins to map in a
     library or unmap it, and again when the mapping change is complete.
     The debugger can set a breakpoint at this address if it wants to
     notice shared object mapping changes.  */
  ElfW(Addr) r_brk;
  enum
    {
      /* This state value describes the mapping change taking place when
         the `r_brk' address is called.  */
      RT_CONSISTENT,          /* Mapping change is complete.  */
      RT_ADD,                 /* Beginning to add a new object.  */
      RT_DELETE               /* Beginning to remove an object mapping.  */
    } r_state;

  ElfW(Addr) r_ldbase;        /* Base address the linker is loaded at.  */
};

With glibc, r_version == 1. At least some versions of Solaris have r_version == 2, and when this is the case there are three extra fields, r_ldsomap, r_rdevent, r_flags. GDB uses r_ldsomap if r_version == 2; the other two seem to be the interface with librtld_db. That’s not documented anywhere to my knowledge, and may not even be fixed: applications are supposed to use the external interface to librtld_db as documented here.

Here is the problem: r_debug, as it stands, has no way to access more than one namespace. The objects in r_map are the default namespace, directly linked, or opened with dlopen, or opened with dlmopen with lmid set to LM_ID_BASE. The r_ldsomap field in Solaris’s r_debug gives access to the linker’s namespace, opened with dlmopen with lmid set to LM_ID_LDSO, but you still can’t see any other namespaces.

glibc uses multiple r_debug structures internally, one per namespace. It would be trivial to add a “next r_debug” link to r_debug if it were possible to extend the structure, but to do this you’d need to set r_version > 2. Applications could arguably expect a runtime linker with r_version > 2 to support the version 2 interface in full, but it wouldn’t be possible to do that in glibc without reverse engineering Solaris’s implementation. glibc is therefore stuck at r_version == 1, and the r_debug structure is effectively immutable for all time.

Syndicated 2013-08-30 11:03:04 from gbenson.net

Garden office

Garden office and view

Since two weeks ago my office has been this hillside hut. It’s a bit of a change from the pokey junkroom I’ve worked from this past twelve years. It’s a bit spartan inside right now–just a desk, a chair and a computer–but I’ll post some pictures later when I’ve jazzed it up a bit.

Syndicated 2013-07-11 12:43:25 from gbenson.net

VM networking tip

If you are setting up VMs using libvirt then it’s a good idea to change the address of the virtual network to something other than the default. Why? Because if you don’t, and you create a guest which itself starts up libvirt and uses NetworkManager then at least some of the time your VM will start up with its networking hosed.

If the host is using the default network (192.168.122.0/24) and the guests also want to use that network then there is a race between NetworkManager bringing up eth0 and libvirt bringing up virbr0. libvirt checks for existing interfaces using the network it is configured for before starting up virbr0, so if NetworkManager brings up eth0 first then virbr0 will not be set up on the guest and everything will be fine. But, if eth0 is not set up by the time libvirt runs the check, then virbr0 will take 192.168.122.0/24, then eth0 will come up on 192.168.122.something, and you’ll have a VM with two separate interfaces connected to two separate networks that both have the same address range… and it won’t work!

The easy way to solve this is to not install libvirt on the guest, but you may not be able to change this until after the guest is running, and if libvirt starts up during a guest’s installer then you may need to complete parts of the installation with no networking. This may or may not be ok for you and your OS. I’m using VMs to set up clean test environments for GDB, and at the moment I’m setting up three or four new “machines” every day (and throwing them away when I’m done) so I want the process as streamlined as possible. If you only occasionally set up new VMs then some extra tasks during the installation may not be a problem, but it is pretty simple to change the network on the host and you only have to do it once:

  1. As root, run virsh net-edit default
  2. Change every occurence of 192.168.122 to something else
  3. Stop any running guests
  4. Run virsh net-destroy default
  5. Run virsh net-start default

It’s a shame this can’t be fixed more conclusively elsewhere, but NetworkManager brings up the interfaces asynchronously at boot time which makes it impossible to definitively schedule libvirt’s startup to happen after NetworkManager.

Thank you Laine Stump for helping me out with this.

Syndicated 2013-05-10 09:37:06 from gbenson.net

Only dest dir longer than base dir not supported

Hello,

Have you experienced the mysterious error, “Only dest dir longer than base dir not supported”?

I have.

The Problem

When you build an rpm, the code is built in %{_builddir}, which usually evaluates as %{_topdir}/BUILD, which in turn evaluates as something like /home/you/rpmbuild/BUILD. The built code (if built with GCC) ends up with loads of /home/you/rpmbuild/BUILD paths embedded in it, and the script /usr/lib/rpm/debugedit rewrites these paths to /usr/src/debug so that the debuginfo rpms work. /usr/lib/rpm/debugedit cannot extend strings, it can only shrink them. If you are seeing “Only dest dir longer than base dir not supported” then, somewhere in your build system, %{_builddir} is defined as something that expands to a string shorter than /usr/src/debug.

Example

In my case, I was building a glibc rpm in a VM that turned out not to have enough disk. I created a new disk, mounted it on /mnt, and added the line %_topdir /mnt to my ~/.rpmmacros. The result? “Only dest dir longer than base dir not supported”. I fixed it by editing ~/.rpmmacros to say %_topdir /mnt/rpmbuild.

Briefly

/usr/src/debug       # the reference
/mnt/BUILD           # too short!
/mnt/rpmbuild/BUILD  # plenty long enough

Thank you,
The Mgt.

Syndicated 2013-05-08 19:50:25 from gbenson.net

267 older entries...

 

gary certified others as follows:

  • gary certified mjcox as Master
  • gary certified joe as Master
  • gary certified tromey as Master
  • gary certified Anthony as Master
  • gary certified leonardr as Journeyer
  • gary certified pedro as Apprentice
  • gary certified nutella as Apprentice
  • gary certified robilad as Master
  • gary certified mjw as Master
  • gary certified timp as Journeyer
  • gary certified aph as Master
  • gary certified twisti as Master
  • gary certified avdyk as Journeyer
  • gary certified gnuandrew as Journeyer

Others have certified gary as follows:

  • chromatic certified gary as Apprentice
  • olandgren certified gary as Apprentice
  • MikeGTN certified gary as Apprentice
  • hub certified gary as Journeyer
  • jao certified gary as Apprentice
  • uweo certified gary as Apprentice
  • sye certified gary as Master
  • cannam certified gary as Journeyer
  • jooon certified gary as Apprentice
  • mike750 certified gary as Journeyer
  • hacker certified gary as Apprentice
  • sad certified gary as Journeyer
  • cdent certified gary as Apprentice
  • opiate certified gary as Journeyer
  • johnnyb certified gary as Apprentice
  • slef certified gary as Apprentice
  • jarod certified gary as Journeyer
  • maelstorm certified gary as Journeyer
  • mjcox certified gary as Journeyer
  • Ausmosis certified gary as Journeyer
  • monk certified gary as Journeyer
  • jono certified gary as Journeyer
  • fxn certified gary as Journeyer
  • ignatz certified gary as Journeyer
  • sethcohn certified gary as Journeyer
  • rupert certified gary as Journeyer
  • larry certified gary as Journeyer
  • sdodji certified gary as Journeyer
  • StevenRainwater certified gary as Journeyer
  • mharris certified gary as Journeyer
  • TheCorruptor certified gary as Journeyer
  • Ilan certified gary as Master
  • criswell certified gary as Master
  • DV certified gary as Journeyer
  • sprite certified gary as Master
  • richdawe certified gary as Journeyer
  • mulix certified gary as Journeyer
  • jrf certified gary as Journeyer
  • rkrishnan certified gary as Journeyer
  • nixnut certified gary as Journeyer
  • jcv certified gary as Journeyer
  • Omnifarious certified gary as Journeyer
  • e8johan certified gary as Journeyer
  • mjw certified gary as Journeyer
  • badvogato certified gary as Master
  • tromey certified gary as Master
  • robilad certified gary as Master
  • reenoo certified gary as Master

[ Certification disabled because you're not logged in. ]

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!

X
Share this page