53 * elf_obj_fini() to complete the concatenation.
54 */
55 static Rt_map *
56 elf_obj_init(Lm_list *lml, Aliste lmco, const char *oname)
57 {
58 Ofl_desc *ofl;
59 const char *name;
60 size_t lmsz;
61
62 /*
63 * Allocate the name of this object, as the original name may be
64 * associated with a data buffer that can be reused to load the
65 * dependencies needed to processes this object.
66 */
67 if ((name = stravl_insert(oname, 0, 0, 0)) == NULL)
68 return (NULL);
69
70 /*
71 * Initialize an output file descriptor and the entrance criteria.
72 */
73 if ((ofl = calloc(sizeof (Ofl_desc), 1)) == NULL)
74 return (NULL);
75
76 ofl->ofl_dehdr = &dehdr;
77
78 ofl->ofl_flags = (FLG_OF_DYNAMIC | FLG_OF_SHAROBJ | FLG_OF_STRIP);
79 ofl->ofl_flags1 = (FLG_OF1_RELDYN | FLG_OF1_TEXTOFF | FLG_OF1_MEMORY);
80 ofl->ofl_lml = lml;
81
82 /*
83 * As ent_setup() will effectively lazy load the necessary support
84 * libraries, make sure ld.so.1 is initialized for plt relocations.
85 * Then configure libld.so to process objects of the desired target
86 * type (this is the first call to libld.so, which will effectively
87 * lazyload it).
88 */
89 if ((elf_rtld_load() == 0) || (ld_init_target(lml, M_MACH) != 0)) {
90 free(ofl);
91 return (NULL);
92 }
93
94 /*
95 * Obtain a generic set of entrance criteria, and generate a link map
96 * place holder and use the ELFPRV() element to maintain the output
97 * file descriptor.
98 */
99 lmsz = S_DROUND(sizeof (Rt_map)) + sizeof (Rt_elfp);
100 if ((ld_ent_setup(ofl, syspagsz) == S_ERROR) ||
101 ((olmp = calloc(lmsz, 1)) == NULL)) {
102 free(ofl);
103 return (NULL);
104 }
105
106 DBG_CALL(Dbg_file_elf(lml, name, 0, 0, lml->lm_lmidstr, lmco));
107 FLAGS(olmp) |= FLG_RT_OBJECT;
108 ELFPRV(olmp) = (void *)ofl;
109
110 /*
111 * Initialize string tables.
112 */
113 if (ld_init_strings(ofl) == S_ERROR) {
114 free(ofl);
115 free(olmp);
116 olmp = NULL;
117 return (NULL);
118 }
119
120 /*
121 * Assign the output file name to be the initial object that got us
122 * here. This name is being used for diagnostic purposes only as we
123 * don't actually generate an output file unless debugging is enabled.
124 */
125 ofl->ofl_name = name;
259 /*
260 * At this point, all input section processing is complete. If any
261 * capabilities have been established, ensure that they are appropriate
262 * for this system.
263 */
264 if (pnavl_recorded(&capavl, ofl->ofl_name, NULL, NULL))
265 scapset = alt_scapset;
266 else
267 scapset = org_scapset;
268
269 if ((((omsk = ofl->ofl_ocapset.oc_hw_1.cm_val) != 0) &&
270 (hwcap1_check(scapset, omsk, &rej) == 0)) ||
271 (((omsk = ofl->ofl_ocapset.oc_sf_1.cm_val) != 0) &&
272 (sfcap1_check(scapset, omsk, &rej) == 0)) ||
273 (((omsk = ofl->ofl_ocapset.oc_hw_2.cm_val) != 0) &&
274 (hwcap2_check(scapset, omsk, &rej) == 0)) ||
275 (((oalp = ofl->ofl_ocapset.oc_plat.cl_val) != NULL) &&
276 (check_plat_names(scapset, oalp, &rej) == 0)) ||
277 (((oalp = ofl->ofl_ocapset.oc_mach.cl_val) != NULL) &&
278 (check_mach_names(scapset, oalp, &rej) == 0))) {
279 if ((lml_main.lm_flags & LML_FLG_TRC_LDDSTUB) && lmp &&
280 (FLAGS1(lmp) & FL1_RT_LDDSTUB) && (NEXT(lmp) == NULL)) {
281 /* LINTED */
282 (void) printf(MSG_INTL(ldd_reject[rej.rej_type]),
283 ofl->ofl_name, rej.rej_str);
284 }
285 return (NULL);
286 }
287
288 /*
289 * Finish creating the output file.
290 */
291 if (ld_make_sections(ofl) == S_ERROR)
292 return (NULL);
293 if (ld_create_outfile(ofl) == S_ERROR)
294 return (NULL);
295 if (ld_update_outfile(ofl) == S_ERROR)
296 return (NULL);
297 if (ld_reloc_process(ofl) == S_ERROR)
298 return (NULL);
299
|
53 * elf_obj_fini() to complete the concatenation.
54 */
55 static Rt_map *
56 elf_obj_init(Lm_list *lml, Aliste lmco, const char *oname)
57 {
58 Ofl_desc *ofl;
59 const char *name;
60 size_t lmsz;
61
62 /*
63 * Allocate the name of this object, as the original name may be
64 * associated with a data buffer that can be reused to load the
65 * dependencies needed to processes this object.
66 */
67 if ((name = stravl_insert(oname, 0, 0, 0)) == NULL)
68 return (NULL);
69
70 /*
71 * Initialize an output file descriptor and the entrance criteria.
72 */
73 if ((ofl = calloc(1, sizeof (Ofl_desc))) == NULL)
74 return (NULL);
75
76 ofl->ofl_dehdr = &dehdr;
77
78 ofl->ofl_flags = (FLG_OF_DYNAMIC | FLG_OF_SHAROBJ | FLG_OF_STRIP);
79 ofl->ofl_flags1 = (FLG_OF1_RELDYN | FLG_OF1_TEXTOFF | FLG_OF1_MEMORY);
80 ofl->ofl_lml = lml;
81
82 /*
83 * As ent_setup() will effectively lazy load the necessary support
84 * libraries, make sure ld.so.1 is initialized for plt relocations.
85 * Then configure libld.so to process objects of the desired target
86 * type (this is the first call to libld.so, which will effectively
87 * lazyload it).
88 */
89 if ((elf_rtld_load() == 0) || (ld_init_target(lml, M_MACH) != 0)) {
90 free(ofl);
91 return (NULL);
92 }
93
94 /*
95 * Obtain a generic set of entrance criteria, and generate a link map
96 * place holder and use the ELFPRV() element to maintain the output
97 * file descriptor.
98 */
99 if ((ld_ent_setup(ofl, syspagsz) == S_ERROR) ||
100 ((olmp = calloc(1, sizeof (Rt_map))) == NULL)) {
101 free(ofl);
102 return (NULL);
103 }
104 DBG_CALL(Dbg_file_elf(lml, name, 0, 0, lml->lm_lmidstr, lmco));
105 FLAGS(olmp) |= FLG_RT_OBJECT;
106 ELFPRV(olmp) = (void *)ofl;
107
108 /*
109 * Initialize string tables.
110 */
111 if (ld_init_strings(ofl) == S_ERROR) {
112 free(ofl);
113 free(olmp);
114 olmp = NULL;
115 return (NULL);
116 }
117
118 /*
119 * Assign the output file name to be the initial object that got us
120 * here. This name is being used for diagnostic purposes only as we
121 * don't actually generate an output file unless debugging is enabled.
122 */
123 ofl->ofl_name = name;
257 /*
258 * At this point, all input section processing is complete. If any
259 * capabilities have been established, ensure that they are appropriate
260 * for this system.
261 */
262 if (pnavl_recorded(&capavl, ofl->ofl_name, NULL, NULL))
263 scapset = alt_scapset;
264 else
265 scapset = org_scapset;
266
267 if ((((omsk = ofl->ofl_ocapset.oc_hw_1.cm_val) != 0) &&
268 (hwcap1_check(scapset, omsk, &rej) == 0)) ||
269 (((omsk = ofl->ofl_ocapset.oc_sf_1.cm_val) != 0) &&
270 (sfcap1_check(scapset, omsk, &rej) == 0)) ||
271 (((omsk = ofl->ofl_ocapset.oc_hw_2.cm_val) != 0) &&
272 (hwcap2_check(scapset, omsk, &rej) == 0)) ||
273 (((oalp = ofl->ofl_ocapset.oc_plat.cl_val) != NULL) &&
274 (check_plat_names(scapset, oalp, &rej) == 0)) ||
275 (((oalp = ofl->ofl_ocapset.oc_mach.cl_val) != NULL) &&
276 (check_mach_names(scapset, oalp, &rej) == 0))) {
277 if ((lml_main.lm_flags & LML_FLG_TRC_LDDSTUB) &&
278 (FLAGS1(lmp) & FL1_RT_LDDSTUB) && (NEXT(lmp) == NULL)) {
279 /* LINTED */
280 (void) printf(MSG_INTL(ldd_reject[rej.rej_type]),
281 ofl->ofl_name, rej.rej_str);
282 }
283 return (NULL);
284 }
285
286 /*
287 * Finish creating the output file.
288 */
289 if (ld_make_sections(ofl) == S_ERROR)
290 return (NULL);
291 if (ld_create_outfile(ofl) == S_ERROR)
292 return (NULL);
293 if (ld_update_outfile(ofl) == S_ERROR)
294 return (NULL);
295 if (ld_reloc_process(ofl) == S_ERROR)
296 return (NULL);
297
|