Struct ldcache_rs::Cache[][src]

pub struct Cache {
    pub version: String,
    pub count: u32,
    pub strlen: Option<u32>,
    pub flags: Option<u8>,
    pub extension_offset: Option<u32>,
    pub entries: HashMap<String, Entry>,
    // some fields omitted
}

Fields

version: String

Cache version as parsed from ld.so.cache (usually 1.1 for the new one)

count: u32

number of entries in the cache (parsed from the ld.so.cache)

strlen: Option<u32>

string table length

flags: Option<u8>

flags for endianness (as of 2.33) values are 0: Not Set 1: Invalid 2: Little 3: Big

extension_offset: Option<u32>

File offset of the extension directory (as of 2.33)

entries: HashMap<String, Entry>

list of entries, we use a hashmap as the use case is more to retrieve a path from a lib name

Implementations

The cache have two possible interpretations

struct file_entry
{
  int flags;		/* This is 1 for an ELF library.  */
  unsigned int key, value; /* String table indices.  */
};

struct cache_file
{
  char magic[sizeof CACHEMAGIC - 1];
  unsigned int nlibs;
  struct file_entry libs[0];
};

#define CACHEMAGIC_NEW "glibc-ld.so.cache"
#define CACHE_VERSION "1.1"
#define CACHEMAGIC_VERSION_NEW CACHEMAGIC_NEW CACHE_VERSION


struct file_entry_new
{
  int32_t flags;		/* This is 1 for an ELF library.  */
  uint32_t key, value;		/* String table indices.  */
  uint32_t osversion;		/* Required OS version.	 */
  uint64_t hwcap;		/* Hwcap entry.	 */
};

struct cache_file_new
{
  char magic[sizeof CACHEMAGIC_NEW - 1];
  char version[sizeof CACHE_VERSION - 1];
  uint32_t nlibs;		/* Number of entries.  */
  uint32_t len_strings;		/* Size of string table. */
  uint32_t unused[5];		/* Leave space for future extensions and align to 8 byte boundary.  */
  struct file_entry_new libs[0]; /* Entries describing libraries.  */
  /* After this the string table of size len_strings is found.	*/
};

as of 2.33 we know use 2 of the unused

struct cache_file_new {
  char magic[sizeof CACHEMAGIC_NEW - 1];
  char version[sizeof CACHE_VERSION - 1];
  uint32_t nlibs;		/* Number of entries.  */
  uint32_t len_strings;		/* Size of string table. */

  /* flags & cache_file_new_flags_endian_mask is one of the values
     cache_file_new_flags_endian_unset, cache_file_new_flags_endian_invalid,
     cache_file_new_flags_endian_little, cache_file_new_flags_endian_big.

     The remaining bits are unused and should be generated as zero and
     ignored by readers.  */
  uint8_t flags;

  uint8_t padding_unsed[3];	/* Not used, for future extensions.  */

  /* File offset of the extension directory.  See struct
     cache_extension below.  Must be a multiple of four.  */
  uint32_t extension_offset;

  uint32_t unused[3];		/* Leave space for future extensions
				   and align to 8 byte boundary.  */
  struct file_entry_new libs[0]; /* Entries describing libraries.  */
  /* After this the string table of size len_strings is found.	*/
};

As a side note, 5 was chosen because you have len_strings which was added compared to the usual format so (5+1)4=24 bytes or 38 bytes.

Utility function, does the contains check on the entries with the full lib name

Utility function, get the entry based on the full lib name

Utility function, get the paths of the lib based on the full lib name

Utility function, get the first path of the lib based on the full lib name

Utility function, create an iterator over the entries

Utility function, return a boolean indicating if there is a partial match As this utility will iterate over all elements, if you need the element please use get_partial or get_path_partial

Utility function, return the first element that contains the key inside the full lib name (partial match)

Utility function, return the first lib paths for which the full lib name contains the key (partial match)

Utility function, return the first lib path for which the full lib name contains the key (partial match)

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.