Print this page
OS-5293 lx brand: prelink(8)'d binaries core dump before main()
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>


1343          */
1344         for (i = 0; i < nphdrs; i++) {
1345                 p_type = STRUCT_FGET(mph, x.p_type);
1346                 if (p_type == PT_LOAD || p_type == PT_SUNWBSS) {
1347                         vaddr = (caddr_t)(uintptr_t)STRUCT_FGET(mph, x.p_vaddr);
1348                         p_memsz = STRUCT_FGET(mph, x.p_memsz);
1349 
1350                         /*
1351                          * Skip this header if it requests no memory to be
1352                          * mapped.
1353                          */
1354                         if (p_memsz == 0) {
1355                                 STRUCT_SET_HANDLE(mph, model,
1356                                     (struct myphdr *)((size_t)STRUCT_BUF(mph) +
1357                                     hsize));
1358                                 MOBJ_STAT_ADD(nomem_header);
1359                                 continue;
1360                         }
1361                         if (num_segs++ == 0) {
1362                                 /*
1363                                  * The p_vaddr of the first PT_LOAD segment
1364                                  * must either be NULL or within the first
1365                                  * page in order to be interpreted.
1366                                  * Otherwise, its an invalid file.





1367                                  */
1368                                 if (e_type == ET_DYN &&
1369                                     ((caddr_t)((uintptr_t)vaddr &
1370                                     (uintptr_t)PAGEMASK) != NULL)) {
1371                                         MOBJ_STAT_ADD(inval_header);
1372                                         return (ENOTSUP);
1373                                 }
1374                                 start_addr = vaddr;
1375                                 /*
1376                                  * For the first segment, we need to map from
1377                                  * the beginning of the file, so we will
1378                                  * adjust the size of the mapping to include
1379                                  * this memory.
1380                                  */
1381                                 p_offset = STRUCT_FGET(mph, x.p_offset);
1382                         } else {
1383                                 p_offset = 0;
1384                         }
1385                         /*
1386                          * Check to make sure that this mapping wouldn't




1343          */
1344         for (i = 0; i < nphdrs; i++) {
1345                 p_type = STRUCT_FGET(mph, x.p_type);
1346                 if (p_type == PT_LOAD || p_type == PT_SUNWBSS) {
1347                         vaddr = (caddr_t)(uintptr_t)STRUCT_FGET(mph, x.p_vaddr);
1348                         p_memsz = STRUCT_FGET(mph, x.p_memsz);
1349 
1350                         /*
1351                          * Skip this header if it requests no memory to be
1352                          * mapped.
1353                          */
1354                         if (p_memsz == 0) {
1355                                 STRUCT_SET_HANDLE(mph, model,
1356                                     (struct myphdr *)((size_t)STRUCT_BUF(mph) +
1357                                     hsize));
1358                                 MOBJ_STAT_ADD(nomem_header);
1359                                 continue;
1360                         }
1361                         if (num_segs++ == 0) {
1362                                 /*
1363                                  * While ELF doesn't specify the meaning of
1364                                  * p_vaddr for PT_LOAD segments in ET_DYN
1365                                  * objects, we mandate that is either NULL or
1366                                  * (to accommodate some historical binaries)
1367                                  * within the first page.  (Note that there
1368                                  * exist non-native ET_DYN objects that violate
1369                                  * this constraint that we nonetheless must be
1370                                  * able to execute; see the ET_DYN handling in
1371                                  * mapelfexec() for details.)
1372                                  */
1373                                 if (e_type == ET_DYN &&
1374                                     ((caddr_t)((uintptr_t)vaddr &
1375                                     (uintptr_t)PAGEMASK) != NULL)) {
1376                                         MOBJ_STAT_ADD(inval_header);
1377                                         return (ENOTSUP);
1378                                 }
1379                                 start_addr = vaddr;
1380                                 /*
1381                                  * For the first segment, we need to map from
1382                                  * the beginning of the file, so we will
1383                                  * adjust the size of the mapping to include
1384                                  * this memory.
1385                                  */
1386                                 p_offset = STRUCT_FGET(mph, x.p_offset);
1387                         } else {
1388                                 p_offset = 0;
1389                         }
1390                         /*
1391                          * Check to make sure that this mapping wouldn't