# lattera/glibc architecture

> Architecture diagram of the GitHub repository lattera/glibc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lattera/glibc
- Repository: https://github.com/lattera/glibc

## Overview

GNU C Library (glibc) is the system API and runtime used by C-compatible applications to access common language, POSIX, and operating-system facilities. A representative lookup workflow is an application requesting a service record, NSS dispatching the request to configured sources, and a backend returning a parsed result; DNS query construction and resolution are a related but distinct network capability. The tree also shows major runtime areas such as startup, dynamic loading, threads, I/O, character conversion, and cryptography. Resolver and service-backend links reflect the sampled excerpts; other subsystem connections are not inferred.

Main entry points: [`nss/service-lookup.c`](https://github.com/lattera/glibc/blob/master/nss/service-lookup.c) (NSS dispatch), [`resolv/res_query.c`](https://github.com/lattera/glibc/blob/master/resolv/res_query.c) (DNS resolver), [`csu/libc-start.c`](https://github.com/lattera/glibc/blob/master/csu/libc-start.c) (Process startup), [`iconv/iconv.c`](https://github.com/lattera/glibc/blob/master/iconv/iconv.c) (Character conversion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_services["Name services"]
  node_service_api["Service lookup API<br/>[service-lookup.c]"]
  node_nss_dispatch["NSS dispatch<br/>[service-lookup.c]"]
  node_files_services["Files backend<br/>[files-service.c]"]
  node_nis_services["NIS backend<br/>[nis-service.c]"]
  node_nisplus_services["NIS+ backend<br/>[nisplus-service.c]"]
  node_hesiod_services["Hesiod backend<br/>[hesiod-service.c]"]
  node_service_cache[("Service cache<br/>[servicescache.c]")]
  node_nscd_protocol["NSCD protocol<br/>[nscd-client.h]"]
end

subgraph group_runtime["Runtime and loading"]
  node_libc_start["Process startup<br/>[libc-start.c]"]
  node_dynamic_loader["Dynamic loader<br/>[rtld.c]"]
end

subgraph group_posix["POSIX facilities"]
  node_threads["POSIX threads<br/>[pt-create.c]"]
  node_stdio["Buffered I/O"]
  node_directories["Directory access<br/>[opendir.c]"]
  node_assertions["Assertions<br/>[assert.c]"]
end

subgraph group_text["Text and conversion"]
  node_character_types["Character types<br/>[ctype.c]"]
  node_iconv_runtime["Character conversion<br/>[iconv.c]"]
  node_conversion_data["Encoding modules"]
end

subgraph group_network["Networking and security"]
  node_resolver["DNS resolver<br/>[res_query.c]"]
  node_query_builder["DNS query builder<br/>[res_mkquery.c]"]
  node_crypt_api["Password hashing<br/>[crypt.c]"]
end

node_application(("C application"))
node_dns_servers(("DNS servers"))
node_kernel(("Operating system"))

node_application -->|"requests service"| node_service_api
node_service_api -->|"dispatches lookup"| node_nss_dispatch
node_nss_dispatch -->|"selects source"| node_files_services
node_nss_dispatch -.->|"selects source"| node_nis_services
node_nss_dispatch -.->|"selects source"| node_nisplus_services
node_nss_dispatch -.->|"selects source"| node_hesiod_services
node_service_cache -->|"resolves service data"| node_files_services
node_application -->|"requests DNS"| node_resolver
node_resolver -->|"builds query"| node_query_builder
node_resolver -->|"sends query"| node_dns_servers
node_dns_servers -->|"returns response"| node_resolver
node_application -->|"starts process"| node_libc_start
node_application -->|"loads shared objects"| node_dynamic_loader
node_application -->|"creates threads"| node_threads
node_application -->|"uses streams"| node_stdio
node_application -->|"reads directories"| node_directories
node_application -->|"checks conditions"| node_assertions
node_application -->|"classifies characters"| node_character_types
node_application -->|"converts encodings"| node_iconv_runtime
node_iconv_runtime -->|"uses conversion modules"| node_conversion_data
node_application -->|"hashes passwords"| node_crypt_api
node_libc_start -->|"initializes process"| node_kernel

click node_service_api "https://github.com/lattera/glibc/blob/master/nss/service-lookup.c"
click node_nss_dispatch "https://github.com/lattera/glibc/blob/master/nss/service-lookup.c"
click node_files_services "https://github.com/lattera/glibc/blob/master/nss/nss_files/files-service.c"
click node_nis_services "https://github.com/lattera/glibc/blob/master/nis/nss_nis/nis-service.c"
click node_nisplus_services "https://github.com/lattera/glibc/blob/master/nis/nss_nisplus/nisplus-service.c"
click node_hesiod_services "https://github.com/lattera/glibc/blob/master/hesiod/nss_hesiod/hesiod-service.c"
click node_service_cache "https://github.com/lattera/glibc/blob/master/nscd/servicescache.c"
click node_nscd_protocol "https://github.com/lattera/glibc/blob/master/nscd/nscd-client.h"
click node_resolver "https://github.com/lattera/glibc/blob/master/resolv/res_query.c"
click node_query_builder "https://github.com/lattera/glibc/blob/master/resolv/res_mkquery.c"
click node_libc_start "https://github.com/lattera/glibc/blob/master/csu/libc-start.c"
click node_dynamic_loader "https://github.com/lattera/glibc/blob/master/elf/rtld.c"
click node_threads "https://github.com/lattera/glibc/blob/master/htl/pt-create.c"
click node_stdio "https://github.com/lattera/glibc/tree/master/libio"
click node_directories "https://github.com/lattera/glibc/blob/master/dirent/opendir.c"
click node_assertions "https://github.com/lattera/glibc/blob/master/assert/assert.c"
click node_character_types "https://github.com/lattera/glibc/blob/master/ctype/ctype.c"
click node_iconv_runtime "https://github.com/lattera/glibc/blob/master/iconv/iconv.c"
click node_conversion_data "https://github.com/lattera/glibc/tree/master/iconvdata"
click node_crypt_api "https://github.com/lattera/glibc/blob/master/crypt/crypt.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_service_api,node_nss_dispatch,node_files_services,node_nis_services,node_nisplus_services,node_hesiod_services,node_service_cache,node_nscd_protocol toneBlue
class node_libc_start,node_dynamic_loader toneAmber
class node_threads,node_stdio,node_directories,node_assertions,node_dns_servers toneMint
class node_character_types,node_iconv_runtime,node_conversion_data toneRose
class node_resolver,node_query_builder,node_crypt_api,node_application,node_kernel toneIndigo
```

## Components

### Name services

- [Service lookup API](https://github.com/lattera/glibc/blob/master/nss/service-lookup.c): `nss/service-lookup.c`
- [NSS dispatch](https://github.com/lattera/glibc/blob/master/nss/service-lookup.c): `nss/service-lookup.c`
- [Files backend](https://github.com/lattera/glibc/blob/master/nss/nss_files/files-service.c): `nss/nss_files/files-service.c`
- [NIS backend](https://github.com/lattera/glibc/blob/master/nis/nss_nis/nis-service.c): `nis/nss_nis/nis-service.c`
- [NIS+ backend](https://github.com/lattera/glibc/blob/master/nis/nss_nisplus/nisplus-service.c): `nis/nss_nisplus/nisplus-service.c`
- [Hesiod backend](https://github.com/lattera/glibc/blob/master/hesiod/nss_hesiod/hesiod-service.c): `hesiod/nss_hesiod/hesiod-service.c`
- [Service cache](https://github.com/lattera/glibc/blob/master/nscd/servicescache.c): `nscd/servicescache.c`
- [NSCD protocol](https://github.com/lattera/glibc/blob/master/nscd/nscd-client.h): `nscd/nscd-client.h`

### Runtime and loading

- [Process startup](https://github.com/lattera/glibc/blob/master/csu/libc-start.c): `csu/libc-start.c`
- [Dynamic loader](https://github.com/lattera/glibc/blob/master/elf/rtld.c): `elf/rtld.c`

### POSIX facilities

- [POSIX threads](https://github.com/lattera/glibc/blob/master/htl/pt-create.c): `htl/pt-create.c`
- [Buffered I/O](https://github.com/lattera/glibc/tree/master/libio): `libio`
- [Directory access](https://github.com/lattera/glibc/blob/master/dirent/opendir.c): `dirent/opendir.c`
- [Assertions](https://github.com/lattera/glibc/blob/master/assert/assert.c): `assert/assert.c`

### Text and conversion

- [Character types](https://github.com/lattera/glibc/blob/master/ctype/ctype.c): `ctype/ctype.c`
- [Character conversion](https://github.com/lattera/glibc/blob/master/iconv/iconv.c): `iconv/iconv.c`
- [Encoding modules](https://github.com/lattera/glibc/tree/master/iconvdata): `iconvdata`

### Networking and security

- [DNS resolver](https://github.com/lattera/glibc/blob/master/resolv/res_query.c): `resolv/res_query.c`
- [DNS query builder](https://github.com/lattera/glibc/blob/master/resolv/res_mkquery.c): `resolv/res_mkquery.c`
- [Password hashing](https://github.com/lattera/glibc/blob/master/crypt/crypt.c): `crypt/crypt.c`

### Other components

- **C application**
- **DNS servers**
- **Operating system**

## Connections

- C application → Service lookup API: requests service
- Service lookup API → NSS dispatch: dispatches lookup
- NSS dispatch → Files backend: selects source
- NSS dispatch → NIS backend: selects source
- NSS dispatch → NIS+ backend: selects source
- NSS dispatch → Hesiod backend: selects source
- Service cache → Files backend: resolves service data
- C application → DNS resolver: requests DNS
- DNS resolver → DNS query builder: builds query
- DNS resolver → DNS servers: sends query
- DNS servers → DNS resolver: returns response
- C application → Process startup: starts process
- C application → Dynamic loader: loads shared objects
- C application → POSIX threads: creates threads
- C application → Buffered I/O: uses streams
- C application → Directory access: reads directories
- C application → Assertions: checks conditions
- C application → Character types: classifies characters
- C application → Character conversion: converts encodings
- Character conversion → Encoding modules: uses conversion modules
- C application → Password hashing: hashes passwords
- Process startup → Operating system: initializes process
