4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
45 * if no sections yet, the file either isn't cooked
46 * or it truly is empty. Then allocate shdr[0]
48 if ((elf
->ed_hdscn
== 0) && (_elf_cook(elf
) != OK_YES
)) {
52 if (elf
->ed_ehdr
== 0) {
53 _elf_seterr(ESEQ_EHDR
, 0);
58 if (elf
->ed_class
== ELFCLASS32
) {
61 if (elf
->ed_hdscn
== 0) {
62 if ((s
= _elf32_snode()) == 0) {
66 s
->sb_scn
.s_elf
= elf
;
67 elf
->ed_hdscn
= elf
->ed_tlscn
= &s
->sb_scn
;
68 s
->sb_scn
.s_uflags
|= ELF_F_DIRTY
;
70 if ((s
= _elf32_snode()) == 0) {
75 s
->sb_scn
.s_elf
= elf
;
76 s
->sb_scn
.s_index
= tl
->s_index
+ 1;
77 elf
->ed_tlscn
= tl
->s_next
= &s
->sb_scn
;
78 ((Elf32_Ehdr
*)elf
->ed_ehdr
)->e_shnum
80 = (Elf32_Half
)(tl
->s_index
+ 2);
81 s
->sb_scn
.s_uflags
|= ELF_F_DIRTY
;
85 } else if (elf
->ed_class
== ELFCLASS64
) {
88 if (elf
->ed_hdscn
== 0) {
89 if ((s
= _elf64_snode()) == 0) {
93 s
->sb_scn
.s_elf
= elf
;
94 elf
->ed_hdscn
= elf
->ed_tlscn
= &s
->sb_scn
;
95 s
->sb_scn
.s_uflags
|= ELF_F_DIRTY
;
97 if ((s
= _elf64_snode()) == 0) {
102 s
->sb_scn
.s_elf
= elf
;
103 s
->sb_scn
.s_index
= tl
->s_index
+ 1;
104 elf
->ed_tlscn
= tl
->s_next
= &s
->sb_scn
;
105 ((Elf64_Ehdr
*)elf
->ed_ehdr
)->e_shnum
107 = (Elf64_Half
)(tl
->s_index
+ 2);
108 s
->sb_scn
.s_uflags
|= ELF_F_DIRTY
;
113 _elf_seterr(EREQ_CLASS
, 0);