Print this page
patch lower-case-segops


1466                 ssize_t shsize;
1467                 char *shstrbase;
1468                 ssize_t shstrsize;
1469 
1470                 Shdr *shdr;
1471                 const char *name;
1472                 size_t sz;
1473                 uintptr_t off;
1474 
1475                 int ctf_ndx = 0;
1476                 int symtab_ndx = 0;
1477 
1478                 /*
1479                  * Since we're just looking for text segments of load
1480                  * objects, we only care about the protection bits; we don't
1481                  * care about the actual size of the segment so we use the
1482                  * reserved size. If the segment's size is zero, there's
1483                  * something fishy going on so we ignore this segment.
1484                  */
1485                 if (seg->s_ops != &segvn_ops ||
1486                     SEGOP_GETVP(seg, seg->s_base, &mvp) != 0 ||
1487                     mvp == lastvp || mvp == NULL || mvp->v_type != VREG ||
1488                     (segsize = pr_getsegsize(seg, 1)) == 0)
1489                         continue;
1490 
1491                 eaddr = saddr + segsize;
1492                 prot = pr_getprot(seg, 1, &tmp, &saddr, &naddr, eaddr);
1493                 pr_getprot_done(&tmp);
1494 
1495                 /*
1496                  * Skip this segment unless the protection bits look like
1497                  * what we'd expect for a text segment.
1498                  */
1499                 if ((prot & (PROT_WRITE | PROT_EXEC)) != PROT_EXEC)
1500                         continue;
1501 
1502                 if (getelfhead(mvp, credp, &ehdr, &nshdrs, &shstrndx,
1503                     &nphdrs) != 0 ||
1504                     getelfshdr(mvp, credp, &ehdr, nshdrs, shstrndx,
1505                     &shbase, &shsize, &shstrbase, &shstrsize) != 0)
1506                         continue;


1897                         prot &= PROT_READ | PROT_WRITE | PROT_EXEC;
1898                         if ((size = (size_t)(naddr - saddr)) == 0)
1899                                 continue;
1900                         if (i == nphdrs) {
1901                                 overflow++;
1902                                 continue;
1903                         }
1904                         v[i].p_type = PT_LOAD;
1905                         v[i].p_vaddr = (Addr)(uintptr_t)saddr;
1906                         v[i].p_memsz = size;
1907                         if (prot & PROT_READ)
1908                                 v[i].p_flags |= PF_R;
1909                         if (prot & PROT_WRITE)
1910                                 v[i].p_flags |= PF_W;
1911                         if (prot & PROT_EXEC)
1912                                 v[i].p_flags |= PF_X;
1913 
1914                         /*
1915                          * Figure out which mappings to include in the core.
1916                          */
1917                         type = SEGOP_GETTYPE(seg, saddr);
1918 
1919                         if (saddr == stkbase && size == stksize) {
1920                                 if (!(content & CC_CONTENT_STACK))
1921                                         goto exclude;
1922 
1923                         } else if (saddr == brkbase && size == brksize) {
1924                                 if (!(content & CC_CONTENT_HEAP))
1925                                         goto exclude;
1926 
1927                         } else if (seg->s_ops == &segspt_shmops) {
1928                                 if (type & MAP_NORESERVE) {
1929                                         if (!(content & CC_CONTENT_DISM))
1930                                                 goto exclude;
1931                                 } else {
1932                                         if (!(content & CC_CONTENT_ISM))
1933                                                 goto exclude;
1934                                 }
1935 
1936                         } else if (seg->s_ops != &segvn_ops) {
1937                                 goto exclude;
1938 
1939                         } else if (type & MAP_SHARED) {
1940                                 if (shmgetid(p, saddr) != SHMID_NONE) {
1941                                         if (!(content & CC_CONTENT_SHM))
1942                                                 goto exclude;
1943 
1944                                 } else if (SEGOP_GETVP(seg, seg->s_base,
1945                                     &mvp) != 0 || mvp == NULL ||
1946                                     mvp->v_type != VREG) {
1947                                         if (!(content & CC_CONTENT_SHANON))
1948                                                 goto exclude;
1949 
1950                                 } else {
1951                                         if (!(content & CC_CONTENT_SHFILE))
1952                                                 goto exclude;
1953                                 }
1954 
1955                         } else if (SEGOP_GETVP(seg, seg->s_base, &mvp) != 0 ||
1956                             mvp == NULL || mvp->v_type != VREG) {
1957                                 if (!(content & CC_CONTENT_ANON))
1958                                         goto exclude;
1959 
1960                         } else if (prot == (PROT_READ | PROT_EXEC)) {
1961                                 if (!(content & CC_CONTENT_TEXT))
1962                                         goto exclude;
1963 
1964                         } else if (prot == PROT_READ) {
1965                                 if (!(content & CC_CONTENT_RODATA))
1966                                         goto exclude;
1967 
1968                         } else {
1969                                 if (!(content & CC_CONTENT_DATA))
1970                                         goto exclude;
1971                         }
1972 
1973                         doffset = roundup(doffset, sizeof (Word));
1974                         v[i].p_offset = doffset;
1975                         v[i].p_filesz = size;




1466                 ssize_t shsize;
1467                 char *shstrbase;
1468                 ssize_t shstrsize;
1469 
1470                 Shdr *shdr;
1471                 const char *name;
1472                 size_t sz;
1473                 uintptr_t off;
1474 
1475                 int ctf_ndx = 0;
1476                 int symtab_ndx = 0;
1477 
1478                 /*
1479                  * Since we're just looking for text segments of load
1480                  * objects, we only care about the protection bits; we don't
1481                  * care about the actual size of the segment so we use the
1482                  * reserved size. If the segment's size is zero, there's
1483                  * something fishy going on so we ignore this segment.
1484                  */
1485                 if (seg->s_ops != &segvn_ops ||
1486                     segop_getvp(seg, seg->s_base, &mvp) != 0 ||
1487                     mvp == lastvp || mvp == NULL || mvp->v_type != VREG ||
1488                     (segsize = pr_getsegsize(seg, 1)) == 0)
1489                         continue;
1490 
1491                 eaddr = saddr + segsize;
1492                 prot = pr_getprot(seg, 1, &tmp, &saddr, &naddr, eaddr);
1493                 pr_getprot_done(&tmp);
1494 
1495                 /*
1496                  * Skip this segment unless the protection bits look like
1497                  * what we'd expect for a text segment.
1498                  */
1499                 if ((prot & (PROT_WRITE | PROT_EXEC)) != PROT_EXEC)
1500                         continue;
1501 
1502                 if (getelfhead(mvp, credp, &ehdr, &nshdrs, &shstrndx,
1503                     &nphdrs) != 0 ||
1504                     getelfshdr(mvp, credp, &ehdr, nshdrs, shstrndx,
1505                     &shbase, &shsize, &shstrbase, &shstrsize) != 0)
1506                         continue;


1897                         prot &= PROT_READ | PROT_WRITE | PROT_EXEC;
1898                         if ((size = (size_t)(naddr - saddr)) == 0)
1899                                 continue;
1900                         if (i == nphdrs) {
1901                                 overflow++;
1902                                 continue;
1903                         }
1904                         v[i].p_type = PT_LOAD;
1905                         v[i].p_vaddr = (Addr)(uintptr_t)saddr;
1906                         v[i].p_memsz = size;
1907                         if (prot & PROT_READ)
1908                                 v[i].p_flags |= PF_R;
1909                         if (prot & PROT_WRITE)
1910                                 v[i].p_flags |= PF_W;
1911                         if (prot & PROT_EXEC)
1912                                 v[i].p_flags |= PF_X;
1913 
1914                         /*
1915                          * Figure out which mappings to include in the core.
1916                          */
1917                         type = segop_gettype(seg, saddr);
1918 
1919                         if (saddr == stkbase && size == stksize) {
1920                                 if (!(content & CC_CONTENT_STACK))
1921                                         goto exclude;
1922 
1923                         } else if (saddr == brkbase && size == brksize) {
1924                                 if (!(content & CC_CONTENT_HEAP))
1925                                         goto exclude;
1926 
1927                         } else if (seg->s_ops == &segspt_shmops) {
1928                                 if (type & MAP_NORESERVE) {
1929                                         if (!(content & CC_CONTENT_DISM))
1930                                                 goto exclude;
1931                                 } else {
1932                                         if (!(content & CC_CONTENT_ISM))
1933                                                 goto exclude;
1934                                 }
1935 
1936                         } else if (seg->s_ops != &segvn_ops) {
1937                                 goto exclude;
1938 
1939                         } else if (type & MAP_SHARED) {
1940                                 if (shmgetid(p, saddr) != SHMID_NONE) {
1941                                         if (!(content & CC_CONTENT_SHM))
1942                                                 goto exclude;
1943 
1944                                 } else if (segop_getvp(seg, seg->s_base,
1945                                     &mvp) != 0 || mvp == NULL ||
1946                                     mvp->v_type != VREG) {
1947                                         if (!(content & CC_CONTENT_SHANON))
1948                                                 goto exclude;
1949 
1950                                 } else {
1951                                         if (!(content & CC_CONTENT_SHFILE))
1952                                                 goto exclude;
1953                                 }
1954 
1955                         } else if (segop_getvp(seg, seg->s_base, &mvp) != 0 ||
1956                             mvp == NULL || mvp->v_type != VREG) {
1957                                 if (!(content & CC_CONTENT_ANON))
1958                                         goto exclude;
1959 
1960                         } else if (prot == (PROT_READ | PROT_EXEC)) {
1961                                 if (!(content & CC_CONTENT_TEXT))
1962                                         goto exclude;
1963 
1964                         } else if (prot == PROT_READ) {
1965                                 if (!(content & CC_CONTENT_RODATA))
1966                                         goto exclude;
1967 
1968                         } else {
1969                                 if (!(content & CC_CONTENT_DATA))
1970                                         goto exclude;
1971                         }
1972 
1973                         doffset = roundup(doffset, sizeof (Word));
1974                         v[i].p_offset = doffset;
1975                         v[i].p_filesz = size;