1 /* 2 * Common functionality. 3 * 4 * Copyright (C) 2022 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include <l4/util/elf.h> 23 24 #include "common.h" 25 26 27 28 /* Find the L4Re auxiliary structure from program argument details. */ 29 30 l4re_aux_t *exec_get_l4re_aux(int argc, char *argv[]) 31 { 32 /* Start after the final terminator (at argc) of the argument vector. */ 33 34 l4_umword_t *arg = ((l4_umword_t *) &argv[argc]) + 1; 35 36 /* The environment vector is traversed. */ 37 38 while (*arg) 39 arg++; 40 41 /* Skip the terminating null entry. */ 42 43 arg++; 44 45 /* Traverse the auxiliary vector. */ 46 47 struct auxv_entry *entry = (struct auxv_entry *) arg; 48 49 for (; entry->key; entry++) 50 { 51 if (entry->key == AT_L4_AUX) 52 return (l4re_aux_t *) entry->value; 53 } 54 55 return NULL; 56 } 57 58 /* vim: tabstop=2 expandtab shiftwidth=2 59 */