summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Lowe <richlowe@richlowe.net>2021-02-17 16:19:26 -0600
committerRichard Lowe <richlowe@richlowe.net>2021-03-05 13:32:27 -0600
commit9f160f41aaee44e207fb709edec8d6493d3c4f2d (patch)
tree1f48c84bb366d618181ce1af619148507a90d2be
parent6d14434bff9ecb720b0d5e27ee39f9ec442f837e (diff)
downloadillumos-joyent-9f160f41aaee44e207fb709edec8d6493d3c4f2d.tar.gz
13565 umem should only have one text section
Reviewed by: Jason King <jason.brian.king+illumos@gmail.com> Reviewed by: Robert Mustacchi <rm+illumos@fingolfin.org> Approved by: Gordon Ross <gordon.w.ross@gmail.com>
-rw-r--r--usr/src/lib/libumem/common/mapfile-vers7
-rw-r--r--usr/src/lib/libumem/common/umem.c23
-rw-r--r--usr/src/lib/libumem/i386/asm_subr.s15
3 files changed, 26 insertions, 19 deletions
diff --git a/usr/src/lib/libumem/common/mapfile-vers b/usr/src/lib/libumem/common/mapfile-vers
index c2cdadf993..66563b3b85 100644
--- a/usr/src/lib/libumem/common/mapfile-vers
+++ b/usr/src/lib/libumem/common/mapfile-vers
@@ -40,11 +40,12 @@
$mapfile_version 2
$if _x86
-LOAD_SEGMENT umem {
+LOAD_SEGMENT ptctext {
FLAGS = READ EXECUTE;
+ ALIGN = 0x1000;
+ ROUND = 0x1000;
ASSIGN_SECTION {
- IS_NAME = .text;
- FILE_BASENAME = asm_subr.o
+ IS_NAME = .ptctext;
};
};
$endif
diff --git a/usr/src/lib/libumem/common/umem.c b/usr/src/lib/libumem/common/umem.c
index 598a45eb39..9c5e3ec829 100644
--- a/usr/src/lib/libumem/common/umem.c
+++ b/usr/src/lib/libumem/common/umem.c
@@ -484,18 +484,17 @@
* -----------------------------------------------
*
* The last piece of this puzzle is how we actually jam ptcmalloc() into the
- * PLT. To handle this, we have defined two functions, _malloc and _free and
- * used a special mapfile directive to place them into the a readable,
- * writeable, and executable segment. Next we use a standard #pragma weak for
- * malloc and free and direct them to those symbols. By default, those symbols
- * have text defined as nops for our generated functions and when they're
- * invoked, they jump to the default malloc and free functions.
- *
- * When umem_genasm() is called, it goes through and generates new malloc() and
- * free() functions in the text provided for by _malloc and _free just after the
- * jump. Once both have been successfully generated, umem_genasm() nops over the
- * original jump so that we now call into the genasm versions of these
- * functions.
+ * PLT. To handle this, we have defined two functions, _malloc and _free, we
+ * use a standard #pragma weak for malloc and free and direct them to those
+ * symbols. By default, those symbols have text defined as nops for our
+ * generated functions and when they're invoked, they jump to the default
+ * malloc and free functions.
+ *
+ * When umem_genasm() is called, it makes _malloc and _free writeable and goes
+ * through and updates the text provided for by _malloc and _free just after
+ * the jump. Once both have been successfully generated, umem_genasm() nops
+ * over the original jump so that we now call into the genasm versions of
+ * these functions, and makes the functions read-only once again.
*
* 8.3 umem_genasm()
* -----------------
diff --git a/usr/src/lib/libumem/i386/asm_subr.s b/usr/src/lib/libumem/i386/asm_subr.s
index 5ad5345c6d..7f7d626487 100644
--- a/usr/src/lib/libumem/i386/asm_subr.s
+++ b/usr/src/lib/libumem/i386/asm_subr.s
@@ -90,8 +90,11 @@ _breakpoint(void)
ret
SET_SIZE(_breakpoint)
#endif
-
- ENTRY(_malloc)
+ .section ".ptctext", "ax"
+ .globl _malloc
+ .type _malloc, @function
+ .align ASM_ENTRY_ALIGN
+_malloc:
jmp umem_malloc;
NOP256
NOP256
@@ -100,7 +103,11 @@ _breakpoint(void)
#endif
SET_SIZE(_malloc)
- ENTRY(_free)
+ .section ".ptctext","ax"
+ .globl _free
+ .type _free, @function
+ .align ASM_ENTRY_ALIGN
+_free:
jmp umem_malloc_free;
NOP256
NOP256
@@ -111,5 +118,5 @@ _breakpoint(void)
ANSI_PRAGMA_WEAK2(malloc,_malloc,function)
ANSI_PRAGMA_WEAK2(free,_free,function)
-
+
#endif /* lint */