156deab07SRod Evans /*
256deab07SRod Evans * CDDL HEADER START
356deab07SRod Evans *
456deab07SRod Evans * The contents of this file are subject to the terms of the
556deab07SRod Evans * Common Development and Distribution License (the "License").
656deab07SRod Evans * You may not use this file except in compliance with the License.
756deab07SRod Evans *
856deab07SRod Evans * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
956deab07SRod Evans * or http://www.opensolaris.org/os/licensing.
1056deab07SRod Evans * See the License for the specific language governing permissions
1156deab07SRod Evans * and limitations under the License.
1256deab07SRod Evans *
1356deab07SRod Evans * When distributing Covered Code, include this CDDL HEADER in each
1456deab07SRod Evans * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1556deab07SRod Evans * If applicable, add the following below this CDDL HEADER, with the
1656deab07SRod Evans * fields enclosed by brackets "[]" replaced with your own identifying
1756deab07SRod Evans * information: Portions Copyright [yyyy] [name of copyright owner]
1856deab07SRod Evans *
1956deab07SRod Evans * CDDL HEADER END
2056deab07SRod Evans */
2156deab07SRod Evans
2256deab07SRod Evans /*
23*f441771bSRod Evans * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
2456deab07SRod Evans */
25*f441771bSRod Evans #ifndef _INLINE_GEN_H
26*f441771bSRod Evans #define _INLINE_GEN_H
2756deab07SRod Evans
2856deab07SRod Evans #include <sys/types.h>
2956deab07SRod Evans #include <sys/mman.h>
30*f441771bSRod Evans #include <rtld.h>
3156deab07SRod Evans
3256deab07SRod Evans inline static mmapobj_result_t *
find_segment(caddr_t roffset,Rt_map * lmp)3356deab07SRod Evans find_segment(caddr_t roffset, Rt_map *lmp)
3456deab07SRod Evans {
3556deab07SRod Evans mmapobj_result_t *mpp = MMAPS(lmp);
3656deab07SRod Evans uint_t mnum = MMAPCNT(lmp);
3756deab07SRod Evans
3856deab07SRod Evans /*
3956deab07SRod Evans * Scan segments backwards. The heaviest use of this function stems
4056deab07SRod Evans * from relocation processing. And typically, relocations are against
4156deab07SRod Evans * the data segment. By scanning segments in reverse order, the data
4256deab07SRod Evans * segment is processed first.
4356deab07SRod Evans */
4456deab07SRod Evans for (mpp += (mnum - 1); mnum; mnum--, mpp--) {
4556deab07SRod Evans if ((roffset >= (mpp->mr_addr + mpp->mr_offset)) &&
4656deab07SRod Evans (roffset < (mpp->mr_addr + mpp->mr_msize)))
4756deab07SRod Evans return (mpp);
4856deab07SRod Evans }
4956deab07SRod Evans return (NULL);
5056deab07SRod Evans }
5156deab07SRod Evans
52*f441771bSRod Evans #endif /* _INLINE_GEN_H */
53