/*-1* SPDX-License-Identifier: BSD-4-Clause2*3* Copyright (c) 1993,1995 Paul Kranenburg4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14* 3. All advertising materials mentioning features or use of this software15* must display the following acknowledgement:16* This product includes software developed by Paul Kranenburg.17* 4. The name of the author may not be used to endorse or promote products18* derived from this software without specific prior written permission19*20* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR21* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES22* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.23* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,24* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT25* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,26* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY27* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT28* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF29* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.30*/3132#include <sys/param.h>33#include <sys/types.h>34#include <sys/stat.h>35#include <sys/mman.h>36#include <a.out.h>37#include <ctype.h>38#include <dirent.h>39#include <elf-hints.h>40#include <err.h>41#include <errno.h>42#include <fcntl.h>43#include <stdbool.h>44#include <stdio.h>45#include <stdlib.h>46#include <string.h>47#include <unistd.h>4849#include "ldconfig.h"50#include "rtld_paths.h"5152static void usage(void) __dead2;5354int55main(int argc, char **argv)56{57const char *hints_file;58int c;59bool is_32, justread, merge, rescan, force_be;6061force_be = is_32 = justread = merge = rescan = false;6263while (argc > 1) {64if (strcmp(argv[1], "-aout") == 0) {65errx(1, "aout is not supported");66} else if (strcmp(argv[1], "-elf") == 0) {67argc--;68argv++;69} else if (strcmp(argv[1], "-32") == 0) {70is_32 = true;71argc--;72argv++;73} else {74break;75}76}7778if (is_32)79hints_file = __PATH_ELF_HINTS("32");80else81hints_file = _PATH_ELF_HINTS;82while((c = getopt(argc, argv, "BRf:imrsv")) != -1) {83switch (c) {84case 'B':85force_be = true;86break;87case 'R':88rescan = true;89break;90case 'f':91hints_file = optarg;92break;93case 'i':94insecure = true;95break;96case 'm':97merge = true;98break;99case 'r':100justread = true;101break;102case 's':103/* was nostd */104break;105case 'v':106/* was verbose */107break;108default:109usage();110break;111}112}113114if (justread) {115list_elf_hints(hints_file);116} else {117if (argc == optind)118rescan = true;119update_elf_hints(hints_file, argc - optind,120argv + optind, merge || rescan, force_be);121}122exit(0);123}124125static void126usage(void)127{128fprintf(stderr,129"usage: ldconfig [-32] [-BRimr] [-f hints_file]"130"[directory | file ...]\n");131exit(1);132}133134135