Solaris Linking Blogs (Combined Index)

Surfing with the Linker-Aliens

[72] elfdiff   [ rie: February 01, 2018 ]

The elfdiff(1) utility analyzes two ELF files and reports the significant differences between them. This utility is targeted at diagnosing the underlying changes that occur within an ELF file through a series of development updates.

[71] kldd: ldd Style Analysis For Solaris Kernel Modules   [ ali: January 11, 2018 ]

The new kldd ELF utility brings ldd style analysis to kernel modules.

[70] Core File Enhancements for elfdump   [ ali: January 10, 2018 ]

Solaris 11.4 comes with a number of enhancements that allow the elfdump utility to display a wealth of information that was previously hidden in Solaris core files. Best of all, this comes without a significant increase in core file size.

[69] ELF Program Header Names   [ ali: January 10, 2018 ]

Starting with Solaris 11.4, program headers in Solaris ELF objects have explicit names associated with them. These names are used by libproc, elfdump, elfedit, pmap, pmadvise, and mdb to eliminate some of the guesswork that goes into looking at process mappings.

[68] How To Strip An ELF Object Without Fully Understanding It   [ ali: April 22, 2016 ]

The simple ELF rules that let programs like strip renumber sections and fix up the sh_link and sh_info section header fields, without understanding the content of the sections involved.

[67] (Not) Managing More Than One Of The Same Object In A Process   [ ali: January 06, 2016 ]

The ways in which more than one ELF object with the same SONAME can end up in a process, what the linkers do to try and prevent it, why that's not completely possible, and why this situation is something to avoid rather than try and manage.

[66] ELF Section Compression   [ ali: December 24, 2015 ]

In cooperation with the GNU community, we are happy and proud to bring standard ELF section compression APIs to libelf. This builds on our earlier work in 2012 (Solaris 11 Update 2) to standardize ELF compression at the file format level. Now, others can easily access that functionality.

[65] ld -ztype, and Kernel Modules That Know What They Are   [ ali: December 23, 2015 ]

Solaris Kernel Modules (kmods) are now explicitly tagged as such, and are treated as final objects.

[64] Regular Expression and Glob Matching for Mapfiles   [ ali: December 23, 2015 ]

Pattern matching using regular expressions, globbing, or plain string comparisons, bring new expressive power to Solaris mapfiles.

[63] New CRT Objects. (Or: What Are CRT objects?)   [ ali: December 22, 2015 ]

Publically documented and committed CRT objects for Solaris.

[62] Goodbye (And Good Riddance) to -mt -and -D_REENTRANT   [ ali: December 22, 2015 ]

A long awaited simplification to the process of building multithreaded code, one of the final projects delivered to Solaris by Roger Faulkner, made possible by his earlier work on thread unification that landed in Solaris 10.

[61] Weak Filters: Dealing With libc Refactoring Over The Years   [ ali: December 21, 2015 ]

Weak Filters allow the link-editor to discard unnecessary libc filters as dependencies, because you can't always fix the Makefile.

[60] Where Did The 32-Bit Linkers Go?   [ ali: December 21, 2015 ]

In Solaris 11 Update 4 (and Solaris 11 Update 3), the 32-bit version of the link-editor, and related linking utilities, are gone.

[59] Solaris 11.4 Beta Is Available   [ ali: January 30, 2018 ]

The Solaris 11.4 Public Beta has been released!

[58] Parent Objects   [ ali: November 26, 2012 ]

A description of Solaris Parent Objects, which were introduced in Solaris 11 Update 1. Parent objects allow plugin objects to be built, with the ld -z defs option, linking against the parent, so that external symbols from the parent can be seen at link time, producing a completely linked object that won't fail to find the external symbols it needs at runtime. This is often referred to as "symbol closure". A side bonus is that the file utility can identify the parent for plugin objects.

[57] Ancillary Objects: Separate Debug ELF Files For Solaris   [ ali: November 26, 2012 ]

Ancillary Objects, an ELF feature introduced with Solaris 11 Update 1, allow the debug sections for an object to be written to a separate file that need not be present for the object to be used at runtime.

[56] elffile: ELF Specific File Identification Utility   [ ali: November 11, 2011 ]

The standard file utility is inconvenient when applied to archives of ELF objects. Introducing elffile, a Solaris utility that provides the same sort of information as file, without requiring the contents of the archive to be unpacked.

[55] The Stub Proto: Not Just For Stub Objects Anymore   [ ali: November 11, 2011 ]

Once we had the stub proto in place for building Solaris, we found additional unanticipated uses for it.

[54] Using Stub Objects   [ ali: November 11, 2011 ]

How to use stub objects to simplify builds, increase build parallelism without complicated makefiles or ordering, and improve object interfaces. Stub objects changed the game for us in terms of build reliability, and the overall build rules are simpler too.

[53] Much Ado About Nothing: Stub Objects   [ ali: November 11, 2011 ]

Solaris 11 delivered a new type of object, known as a stub. A stub object is an object, built entirely from mapfiles, that supplies the same linking interface as the real object, while containing no code or data. This post describes the long process from idea to practical reality used every day to build the Solaris OS.

[52] Nagging As A Strategy For Better Linking: -z guidance   [ ali: November 11, 2011 ]

Like most long lived tools, the linkers have some unfortunate defaults. In addition, there are newer abilities that people don't always use. How do you push the world to use that stuff, without breaking existing applications?

[51] 64-bit Archives Needed   [ ali: November 11, 2011 ]

How Solaris ELF archives were extended so that ELF archives can exceed the 32-bit 2GB file size limit, with a discussion of how other Unix like systems have tackled the same problem.

[50] Solaris 11   [ ali: November 11, 2011 ]

Solaris 11: A few new ELF and linking features: 64-bit archives, ld guidance, stub objects, elffile.

[49] How To Name A Solaris Shared Object   [ ali: October 15, 2010 ]

The rules that govern how Solaris shared objects are named, with a deep dive on how SONAMEs and compilation symlinks conspire to let you link with the latest version of a library, while old programs continue to run with the old versions of the same library.

[48] Symbol Capabilities   [ rie: August 02, 2010 ]

Symbol capabilities are capabilities that are associated with individual functions, or initialized data items, within an object. Symbol capabilities allow for the presence of multiple instances of a function within a single object. The runtime linker selects the best one for the running system. This is how Solaris provides optimized implementations of routines (e.g. memcpy) with a generic fallback.

[47] A New Mapfile Syntax for Solaris   [ ali: January 07, 2010 ]

An overview of the new version 2 Solaris Mapfile Language. Version 2 mapfiles are human readable, and provide a basis for the addition of future link-editor features in ways that the original language can't support.

[46] The Problem(s) With Solaris SVR4 Link-Editor Mapfiles   [ ali: January 06, 2010 ]

I was a Sun user and ISV for many years before joining the Solaris group, and I wrote more than my share of low level C code, and used all the various compilers, linkers, and debuggers. And yet, I never fully understood the cryptic and odd Solaris link-editor mapfile language that was inherited with Sysv Unix from AT&T. When I joined Sun, I got the job of designing its replacement, and had to sit down and fully map it out. I realized that if I didn't write it down, I'd forget it all again, as it's just that cryptic. The best way to use this is to decode your existing mapfiles and then rewrite them in the the version 2 mapfile language.

[45] GNU Hash ELF Sections   [ ali: October 21, 2008 ]

Solaris doesn't use the GNU hash, but I wanted to understand it in enough detail to be able to implement it, and while I found bits and pieces of what I needed on the web, there was no single detailed description. I ended up contacting the authors to clarify and explain some bits. They were generous with their time, and helped me out. In return, here is a detailed description of the GNU hash, with enough background to understand it.

[44] The Cost Of ELF Symbol Hashing   [ ali: October 21, 2008 ]

Standard ELF uses hash sections that are essentially unchanged since they were defined at AT&T in the 1980's. GNU have created their own replacements for these, in the interest of speeding up the hash process. Here, I consider the costs involved in ELF hashing, and highlight the difference in approach between Solaris, which uses direct bindings to drive down these costs (as well as other benefits), and the GNU hash which seeks to drive out all the unnecessary computational overhead of classic ELF symbol lookup.

[43] Direct Binding - the -zdirect/-Bdirect options, and probing   [ rie: July 21, 2008 ]

The difference between the -z direct and -B direct options, and a useful technique for handling the case where the lazy dependency is not present at runtime.

[42] OSNet Direct Binding   [ rie: May 14, 2008 ]

The core Solaris OS is now built with Direct Binding. A discussion of the benefits, and the process used to get there safely.

[41] ld Is Now A Cross Link-Editor   [ ali: March 19, 2008 ]

The Solaris link-editor (ld) has the ability to link objects for a target machine different than the one doing the link. As an example, you can link sparc objects while running on an x86 based system.

[40] Avoiding LD_LIBRARY_PATH: The Options   [ ali: November 02, 2007 ]

The LD_LIBRARY_PATH environment is a necessary evil that is used far more often than it should be. With the addition of the elfedit utility, I revisit this old topic, describing the many ways in which LD_LIBRARY_PATH can bite, provide some strategies for reducing its use, and some guidelines on how to manage its use if you must use it.

[39] Introducing elfedit   [ ali: November 02, 2007 ]

elfedit is a new Solaris utility that allows for arbitrary in place editing of ELF objects. It's a boon for debugging, and testing, and early experimentation, and it finally provides a way for people who are not comfortable editing ELF objects in emacs to alter the runpath of an object. It's an expert tool, so it can also break objects, which is in itself useful in a development environment.

[38] What Are Fake ELF Section Headers?   [ ali: November 01, 2007 ]

elfdump gains the ability to ignore the section headers in and ELF object, and instead synthesize a set based on the program headers. This can be useful if the object has been damaged, or if you suspect that it's been tampered with maliciously, because unlike section headers, program headers reflect the information actually seen by the runtime linker, and therefore reveal "truth" that might be obscured in tampered section headers. It's an obscure and hopefully rarely used feature that's nice to have in the toolbox.

[37] We've moved - /usr/ccs/bin commands, that is   [ rie: June 25, 2007 ]

The link-editor, and associated utilities, have moved from /usr/ccs/bin utilities to /usr/bin.

[36] Changing ELF Runpaths (Code Included)   [ ali: June 12, 2007 ]

One of the goals that led to the development of the elfedit utility was to enable modifying the runpath of an existing object without having to relink it. The changes to Solaris ELF objects required to support that are described here, and a simple program to do that named rpath is provided. Today we have elfedit, so there's no reason to use rpath, but it still serves as documentation.

[35] Which Solaris Files Are Stripped?   [ ali: February 09, 2007 ]

In the previous posting about the new .SUNW_ldynsym sections, I claimed that Solaris objects have been shipped in unstripped form for many years. I learned later that this is only partially true, and that things were greatly improved with Solaris 10. This article gives the details.

[34] What Is .SUNW_ldynsym?   [ ali: February 07, 2007 ]

Solaris ELF files have a new ELF symbol table. The section type is SHT_SUNW_LDYNSYM, and the section is named .SUNW_ldynsym. In the 20+ years in which the ELF standard has been in use, we have only needed two symbol tables (.symtab, and .dynsym) to support linking, so the addition of a third symbol table is a notable event for ELF cognoscenti. Even if you aren't one of those, you may encounter these sections, and wonder what they are for.

[33] '_init'/'_fini' not found - use the compiler drivers   [ rie: December 19, 2006 ]

It's best not to use ld() directly to build any executables or shared objects, let the compiler drivers do it for you.

[32] Displacement Relocation Warnings - what do they mean?   [ rie: October 13, 2006 ]

[31] Dynamic Object Versioning - specifying a version binding   [ rie: October 13, 2006 ]

How to restrict an application to only use the interfaces defined by specific ELF versions.

[30] Changing Search Paths with crle(1) - they are a replacement   [ rie: October 04, 2006 ]

The crle utility replaces the system default library directories, and can easily brick your system if you are not careful. An explanation, and how to recover.

[29] Inside ELF Symbol Tables   [ ali: September 23, 2006 ]

ELF symbol tables, and the rules and conventions that govern their layout.

[28] What Are "Tentative" Symbols?   [ ali: September 22, 2006 ]

An exploration of the mess that is Unix "tentative" symbols, also known as "common" symbols, and a tip on how to prevent them from happening in your code.

[27] Settling An Old Score (Linker Division)   [ ali: June 14, 2006 ]

I used SunOS and later Solaris for many years before joining Sun. Joining the Solaris group allowed me to fix a classic misfeature of the link-editor, and cause output files to be unlinked before being created, rather than writing the new content in place.

[26] Wrong ELF Class - requires consistent compiler flags   [ rie: April 26, 2006 ]

How "wrong ELFCLASS" errors can be caused by missing or inconsistent compiler flags.

[25] Testing Critical System Components Without Turning Your System Into A Brick   [ ali: April 19, 2006 ]

In the past, a programming mistake in the runtime linker could immediately brick your system (render it unusable), and recovery was slow and tedious (boot the CD, put back the old runtime linker, reboot). Solaris Zones provide the option to employ a dirty and unsupported, but very useful trick for testing new development linker components without the risk of bricking the box.

[24] C++ Dynamic Linking - symbol visibility issues   [ rie: March 16, 2006 ]

The challenges of C++ symbol visibility in a dynamic linking environment, and singletons.

[23] Runtime Token Expansion - some clarification   [ rie: December 14, 2005 ]

The limitations of runtime token processing.

[22] A Very Slow Link-Edit - get the latest patch   [ rie: October 13, 2005 ]

[21] Init and Fini Processing - who designed this?   [ rie: September 27, 2005 ]

People often assume far more from runtime .init/.fini processing than is actually provided, and use it far too casually. Such code runs in a limited environment, and with many caveats.

[20] Finding Symbols - reducing dlsym() overhead   [ rie: September 09, 2005 ]

Techniques for avoiding the unexpected costs that can be incurred dlsym() in a lazy loading environment.

[19] The Link-editors - a source tour   [ rie: June 14, 2005 ]

[18] Library Bindings - let's be a little bit more precise shall we   [ msw: June 14, 2005 ]

How the runtime library binds objects at runtime, and the application direct bindings to improve efficiency and precision.

[17] Loading Multiple Files - same name, different directories   [ rie: May 08, 2005 ]

[16] My Relocations Don't Fit - Position Independence   [ rie: April 26, 2005 ]

Relocation "does not fit" usually result from forgetting to create position independent (PIC) code.

[15] Loading Relocatable Objects at Runtime - Very Expensive   [ rie: February 02, 2005 ]

[14] Interface Creation - using the compilers   [ rie: January 02, 2005 ]

The limitations of using mapfiles for interface creation, particularly with languages like C++, and the alternative of using source visibility attributes.

[13] Static Linking - where did it go?   [ rie: December 06, 2004 ]

Starting with Solaris 10 you can no longer build a completely static executable. A discussion of the underlying reasons, and of the resulting benefits.

[12] Shared Object Filters   [ rie: October 22, 2004 ]

Standard and Auxiliary filters

[11] Tracing a link-edit   [ rie: September 29, 2004 ]

How to use the extensive built in linking debug facility to trace what your programs are doing at runtime.

[10] Relocations - careful with that debugging flag   [ rie: August 30, 2004 ]

The potential cost of debug options at runtime can be higher than you realize.

[9] Dynamic Object Versioning   [ rie: August 22, 2004 ]

Examining ELF versioning within the core OS.

[8] Lazy Loading - there's even a fall back   [ rie: August 01, 2004 ]

A discussion of the potentially expensive fall back mechanism that underlies lazy loading.

[7] Dependencies - perhaps they can be lazily loaded   [ rie: July 27, 2004 ]

Consider using lazy loading to make your applications start faster and do less unnecessary work.

[6] Linker Alien Spotting   [ rie: July 22, 2004 ]

[5] How to build a Shared Library   [ msw: July 22, 2004 ]

How to build shared libraries properly.

[4] Hello World   [ msw: July 22, 2004 ]

[3] Dependencies - define what you need, and nothing else   [ rie: July 15, 2004 ]

The costs of linking against libraries you don't use, and how to detect when you're doing it.

[2] LD_LIBRARY_PATH - just say no   [ rie: July 10, 2004 ]

The many ways in which LD_LIBRARY_PATH will let you down. There are usually better answers.

[1] Hello there   [ rie: July 07, 2004 ]