xref: /illumos-gate/usr/src/cmd/sgs/libelf/common/data.c (revision 3c573fcc51430b02603f62713f3f5d1b0b1aed1c)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51d2738a5Sraf  * Common Development and Distribution License (the "License").
61d2738a5Sraf  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
211d2738a5Sraf 
227c478bd9Sstevel@tonic-gate /*
23*3c573fccSAli Bahrami  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
241d2738a5Sraf  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277257d1b4Sraf /*	Copyright (c) 1988 AT&T	*/
287257d1b4Sraf /*	  All Rights Reserved  	*/
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #include <libelf.h>
317c478bd9Sstevel@tonic-gate #include "decl.h"
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate  * Global data
357c478bd9Sstevel@tonic-gate  * _elf_byte		Fill byte for file padding.  See elf_fill().
367c478bd9Sstevel@tonic-gate  * _elf32_ehdr_init	Clean copy for to initialize new headers.
377c478bd9Sstevel@tonic-gate  * _elf64_ehdr_init	Clean copy for to initialize new class-64 headers.
387c478bd9Sstevel@tonic-gate  * _elf_encode		Host/internal data encoding.  If the host has
397c478bd9Sstevel@tonic-gate  *			an encoding that matches one known for the
407c478bd9Sstevel@tonic-gate  *			ELF format, this changes.  An machine with an
417c478bd9Sstevel@tonic-gate  *			unknown encoding keeps ELFDATANONE and forces
427c478bd9Sstevel@tonic-gate  *			conversion for host/target translation.
437c478bd9Sstevel@tonic-gate  * _elf_work		Working version given to the lib by application.
447c478bd9Sstevel@tonic-gate  *			See elf_version().
457c478bd9Sstevel@tonic-gate  * _elf_globals_mutex	mutex to protect access to all global data items.
46*3c573fccSAli Bahrami  * _elf_execfill_func	Fill function for file padding of SHF_EXECINSTR
47*3c573fccSAli Bahrami  *			sections. See _elf_execfill().
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /*
511d2738a5Sraf  * __libc_threaded is a private symbol exported from libc in Solaris 10.
521d2738a5Sraf  * It is used to tell if we are running in a threaded world or not.
531d2738a5Sraf  * Between Solaris 2.5 and Solaris 9, this was named __threaded.
541d2738a5Sraf  * The name had to be changed because the Sun Workshop 6 update 1
551d2738a5Sraf  * compilation system used it to mean "we are linked with libthread"
561d2738a5Sraf  * rather than its true meaning in Solaris 10, "more than one thread exists".
577c478bd9Sstevel@tonic-gate  */
581d2738a5Sraf #pragma weak		__libc_threaded
591d2738a5Sraf extern int		__libc_threaded;
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate int			_elf_byte = 0;
627c478bd9Sstevel@tonic-gate const Elf32_Ehdr	_elf32_ehdr_init = { 0 };
637c478bd9Sstevel@tonic-gate const Elf64_Ehdr	_elf64_ehdr_init = { 0 };
647c478bd9Sstevel@tonic-gate unsigned		_elf_encode = ELFDATANONE;
65*3c573fccSAli Bahrami _elf_execfill_func_t	*_elf_execfill_func = NULL;
667c478bd9Sstevel@tonic-gate const Snode32		_elf32_snode_init = { 0 };
677c478bd9Sstevel@tonic-gate const Snode64		_elf64_snode_init = { 0 };
687c478bd9Sstevel@tonic-gate const Dnode		_elf_dnode_init = { 0 };
697c478bd9Sstevel@tonic-gate unsigned		_elf_work = EV_NONE;
707c478bd9Sstevel@tonic-gate mutex_t			_elf_globals_mutex = DEFAULTMUTEX;
717c478bd9Sstevel@tonic-gate 
721d2738a5Sraf int			*_elf_libc_threaded = &__libc_threaded;
73