[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] gawk branch, stable/pma-update, updated. gawk-4.1.0-5627-g1df8d338
From: |
Arnold Robbins |
Subject: |
[SCM] gawk branch, stable/pma-update, updated. gawk-4.1.0-5627-g1df8d338 |
Date: |
Wed, 5 Feb 2025 14:08:05 -0500 (EST) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, stable/pma-update has been updated
via 1df8d33802b1b5e69c948c75218edede5eb47f0c (commit)
via c998dfe81581ddb80e77a0b737beb619629ee297 (commit)
via 8e00d6f75321b38fbbacbc69a2fca99adc0d31bd (commit)
via 3fcf4ea97e1875717979dafc8a8bdbf2bb8b50e0 (commit)
via 516079d0dbbf0cda3c6226c93b7c96bee0c3ab70 (commit)
via ca91101068fa3b84006aca5764ce10d3d56e2486 (commit)
via 05e85466a2db546a65e2514e8a10b1fbf977ff44 (commit)
via 101800ca4a9ce86070cc3b062dd13f1999a75db3 (commit)
via ec02a78fd00234cb948437f43014a40c3030245a (commit)
via d164489e614c602397f50efb01da8b99b4cd6831 (commit)
via 6749e9972375566e820d14081b5b79189f8a0d16 (commit)
via 90f6c3ed3e41e881f624fb805d2321eb80122357 (commit)
via 031f662150a46933f856b42d586741cf42dea4c3 (commit)
via 4123430172a2119cd99a3f5211917d7f4edb4f3f (commit)
via 28c67338510f6ca025f4be8451dd72fbb690e543 (commit)
via 9c0d9ba9542f415221482dd9c5a797326c704fb1 (commit)
via 136e88a134dca730dad3faee21c1cc864347ff1e (commit)
via 650d32c6b8b0f925b707dae65c17a42422530b05 (commit)
from fa4c50ff714e7a80512f4bda655e9384919aa701 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=1df8d33802b1b5e69c948c75218edede5eb47f0c
commit 1df8d33802b1b5e69c948c75218edede5eb47f0c
Merge: c998dfe8 8e00d6f7
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Wed Feb 5 21:06:25 2025 +0200
Merge branch 'gawk-5.3-stable' into stable/pma-update
diff --cc ChangeLog
index a27d28d6,6e94266e..2e9d6c7d
--- a/ChangeLog
+++ b/ChangeLog
@@@ -1,27 -1,23 +1,47 @@@
+2025-02-05 Arnold D. Robbins <arnold@skeeve.com>
+
+ * configure.ac: Add checks for spawn.h and _NSGetExecutablePath
+ function.
+ * awk.h (os_disable_aslr): Add function declaration.
+ * main.c (enable_pma): Move OS specific code out of this function
+ and in posix/gawkmisc.c. Instead, call os_disable_aslr().
+
+2025-02-05 Arnold D. Robbins <arnold@skeeve.com>
+
+ * main.c (enable_pma): Remove unused argc parameter and adjust
+ call. Add call to unsetenv() for magic env var if it was
+ there, so that the environment is as it was before the exec.
+
+2025-02-05 Arnold D. Robbins <arnold@skeeve.com>
+
+ * main.c (enable_pma): New function. Has the entire init flow
+ for PMA. Also has new linux-specific code to deal with being
+ an PIE executable.
+ (main): Call enable_pma().
+ * configure.ac: Add checks for <sys/personality.h> and the
+ personality() system call.
+ * NEWS: Updated.
+
+ 2025-02-05 Arnold D. Robbins <arnold@skeeve.com>
+
+ Bug fixes for indirect calls of match and patsplit.
+ Thanks to Denis Shirokov <cosmogen@gmail.com> for the report
+ and test case.
+
+ * builtin.c (call_match): Pop the text of the stack. Handle
+ the case that the regex is Node_var_new or Node_elem_new.
+ Same for the text. Push text onto the stack first, then
+ everything else.
+ Also, free the vname for the regex argument if it's a Node_var_new;
+ same for the text argument.
+ * eval.c (setup_frame): Handle Node_regex and Node_dynregex.
+ * field.c (do_patsplit): Handle the case of the source being
+ Node_param_list, and then if Node_var_new or Node_elem_new.
+
+ 2025-02-05 Arnold D. Robbins <arnold@skeeve.com>
+
+ * node.c (r_unref): For Node_var_new, free the vname.
+
2025-02-05 Arnold D. Robbins <arnold@skeeve.com>
Stylistic cleanups and small code cleanups.
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=c998dfe81581ddb80e77a0b737beb619629ee297
commit c998dfe81581ddb80e77a0b737beb619629ee297
Merge: 101800ca fa4c50ff
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Wed Feb 5 21:05:22 2025 +0200
Merge branch 'stable/pma-update' of ssh://git.sv.gnu.org/srv/git/gawk into
stable/pma-update
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=101800ca4a9ce86070cc3b062dd13f1999a75db3
commit 101800ca4a9ce86070cc3b062dd13f1999a75db3
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Sun Feb 2 11:21:12 2025 +0200
Update NEWS.
diff --git a/NEWS b/NEWS
index 2eb6d5a5..cf05f011 100644
--- a/NEWS
+++ b/NEWS
@@ -15,7 +15,9 @@ Changes from 5.3.1 to 5.3.x
2. OpenVMS 9.2-2 x86_64 is now supported.
-3. On Linux systems, the -no-pie linker flag is no longer required.
+3. On Linux and macos systems, the -no-pie linker flag is no longer required.
+ PMA now works on macos systems with Apple silicon, and not just
+ Intel systems.
XX. As usual, there have been several minor code cleanups and bug fixes.
See the ChangeLog for details.
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=ec02a78fd00234cb948437f43014a40c3030245a
commit ec02a78fd00234cb948437f43014a40c3030245a
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Sat Feb 1 19:55:16 2025 +0200
Some cleanups.
diff --git a/extension/configure b/extension/configure
index 45aac712..a6e6381c 100755
--- a/extension/configure
+++ b/extension/configure
@@ -8795,17 +8795,7 @@ fi
true # On Linux we no longer need -no-pie
;;
*darwin*)
- # 27 November 2022: PMA only works on Intel.
- case $host in
- x86_64-*)
- LDFLAGS="${LDFLAGS} -Xlinker -no_pie"
- export LDFLAGS
- ;;
- *)
- # disable on all other macOS systems
- use_persistent_malloc=no
- ;;
- esac
+ true # On macos we no longer need -no-pie
;;
*cygwin* | *CYGWIN* | *solaris2.11* | freebsd13.* | openbsd7.* )
true # nothing to do, exes on these systems are not
PIE
diff --git a/main.c b/main.c
index 191e2b6a..0e79bec0 100644
--- a/main.c
+++ b/main.c
@@ -1912,9 +1912,6 @@ check_pma_security(const char *pma_file)
#endif /* USE_PERSISTENT_MALLOC */
}
-//#include <libproc.h>
-#include <spawn.h>
-
/* enable_pma --- do the PMA flow, handle ASLR on Linux */
static bool
diff --git a/posix/gawkmisc.c b/posix/gawkmisc.c
index 9a5c9a46..1656ae96 100644
--- a/posix/gawkmisc.c
+++ b/posix/gawkmisc.c
@@ -308,6 +308,8 @@ os_maybe_set_errno(void)
/* os_disable_aslr --- disable Address Space Layout Randomization */
+// This for Linux and MacOS. It's not needed on other *nix systems.
+
void
os_disable_aslr(const char *persist_file, char **argv)
{
@@ -379,8 +381,6 @@ os_disable_aslr(const char *persist_file, char **argv)
#endif
}
-// This for Linux and MacOS. It's not needed on other *nix systems.
-
// For MSYS, restore behavior of working in text mode.
#ifdef __MSYS__
void
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=d164489e614c602397f50efb01da8b99b4cd6831
commit d164489e614c602397f50efb01da8b99b4cd6831
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Sat Feb 1 19:49:12 2025 +0200
Doc updates.
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 595d3c9d..30ee9cd2 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,9 @@
+2025-02-01 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawk.1: Remove note that persistent memory is experimental.
+ * gawk.texi (Persistent Memory): Remove stuff related to PIE
+ and ASLR.
+
2025-01-22 Arnold D. Robbins <arnold@skeeve.com>
* gawk.texi (Persistent Memory): Note that if a Linux system
diff --git a/doc/gawk.1 b/doc/gawk.1
index 4656940f..28092569 100644
--- a/doc/gawk.1
+++ b/doc/gawk.1
@@ -13,7 +13,7 @@
. if \w'\(rq' .ds rq "\(rq
. \}
.\}
-.TH GAWK 1 "Apr 24 2024" "Free Software Foundation" "Utility Commands"
+.TH GAWK 1 "Feb 2 2025" "Free Software Foundation" "Utility Commands"
.SH NAME
gawk \- pattern scanning and processing language
.SH SYNOPSIS
@@ -2291,7 +2291,6 @@ The
.B GAWK_PERSIST_FILE
environment variable, if present, specifies a file to use as
the backing store for persistent memory.
-.IR "This is an experimental feature" .
See \*(EP for the details.
.PP
The
diff --git a/doc/gawk.info b/doc/gawk.info
index 191b968b..907532bc 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -22701,11 +22701,10 @@ the filesystem. When persistent memory is not in use
(the normal case),
âgawkâ's data resides in ephemeral system memory.
Persistent memory is enabled on certain 64-bit systems supporting the
-âmmap()â and âmunmap()â system calls. âgawkâ must be compiled as a
-non-PIE (Position Independent Executable) binary, since the persistent
-store ends up holding pointers to functions held within the âgawkâ
-executable. This also means that to use the persistent memory, you must
-use the same âgawkâ executable from run to run.
+âmmap()â and âmunmap()â system calls. Since the persistent store ends
+up holding pointers to functions held within the âgawkâ executable, in
+order to use persistent memory, you must use the same âgawkâ executable
+from run to run.
You can see if your version of âgawkâ supports persistent memory like
so:
@@ -22718,12 +22717,12 @@ so:
If you see the âPMAâ with a version indicator, then it's supported.
As of this writing, persistent memory has only been tested on
-GNU/Linux, Cygwin, Solaris 2.11, Intel architecture macOS systems,
-FreeBSD 13.1 and OpenBSD 7.1. On all others, persistent memory is
-disabled by default. You can force it to be enabled by exporting the
-shell variable âREALLY_USE_PERSIST_MALLOCâ with a nonempty value before
-running âconfigureâ (*note Quick Installation::). If you do so and all
-the tests pass, please let the maintainer know.
+GNU/Linux, Cygwin, Solaris 2.11, macOS, FreeBSD 13.1 and OpenBSD 7.1.
+On all others, persistent memory is disabled by default. You can force
+it to be enabled by exporting the shell variable
+âREALLY_USE_PERSIST_MALLOCâ with a nonempty value before running
+âconfigureâ (*note Quick Installation::). If you do so and all the
+tests pass, please let the maintainer know.
To use persistent memory, follow these steps:
@@ -22758,11 +22757,12 @@ the tests pass, please let the maintainer know.
variables, such as âNRâ, are reset upon each run. Only the
variables defined by the program are preserved across runs.
- Interestingly, the program that you execute need not be the same from
-run to run; the persistent store only maintains the values of variables,
-arrays, and user-defined functions, not the totality of âgawkâ's
-internal state. This lets you share data between unrelated programs,
-eliminating the need for scripts to communicate via text files.
+ Interestingly, the âawkâ program that you execute need not be the
+same from run to run; the persistent store only maintains the values of
+variables, arrays, and user-defined functions, not the totality of
+âgawkâ's internal state. This lets you share data between unrelated
+âawkâ programs, eliminating the need for scripts to communicate via text
+files.
Terence Kelly, the author of the persistent memory allocator âgawkâ
uses, provides the following advice about the backing file:
@@ -22802,15 +22802,6 @@ the different verbosity levels are.
⢠The GNU/Linux CIFS filesystem is known to not work well with the
PMA allocator. Don't use a backing file on a CIFS filesystem.
- ⢠Some GNU/Linux distributions enable Address Space Layout
- Randomization (ASLR) by default. This breaks âgawkâ's use of the
- PMA allocator. You can work around this using âsetarch -R gawk
- ...â to run âgawkâ; this disables ASLR for the particular execution
- of âgawkâ. If ASLR is the default on your system, and you want to
- use persistent memory, you may wish to set up a shell alias, shell
- function, or shell script to run âgawkâ by way of the âsetarchâ
- command.
-
⢠If âgawkâ is run by the ârootâ user, then persistent memory is
not
allowed. This is to avoid the possibility of private data
"leaking" into the backing file and being recovered later by an
@@ -37797,7 +37788,7 @@ Index
* environment variables, GAWK_PERSIST_FILE: Other Environment Variables.
(line 15)
* environment variables, GAWK_PERSIST_FILE <1>: Persistent Memory.
- (line 50)
+ (line 49)
* environment variables, GAWK_READ_TIMEOUT: Other Environment Variables.
(line 19)
* environment variables, GAWK_READ_TIMEOUT <1>: Read Timeout. (line 71)
@@ -37831,7 +37822,7 @@ Index
* environment variables, POSIXLY_CORRECT <3>: Locale influences conversions.
(line 41)
* environment variables, REALLY_USE_PERSIST_MALLOC: Persistent Memory.
- (line 29)
+ (line 28)
* environment variables, STR_CHAIN_MAX: Other Environment Variables.
(line 91)
* environment variables, TIDYMEM: Other Environment Variables.
@@ -38299,7 +38290,7 @@ Index
* GAWK_PERSIST_FILE environment variable: Other Environment Variables.
(line 15)
* GAWK_PERSIST_FILE environment variable <1>: Persistent Memory.
- (line 50)
+ (line 49)
* GAWK_READ_TIMEOUT environment variable: Other Environment Variables.
(line 19)
* GAWK_READ_TIMEOUT environment variable <1>: Read Timeout. (line 71)
@@ -38571,7 +38562,7 @@ Index
* Kahrs, Jürgen <1>: Contributors. (line 71)
* Kasal, Stepan: Acknowledgments. (line 60)
* Kelly, Terence: Persistent Memory. (line 76)
-* Kelly, Terence <1>: Persistent Memory. (line 147)
+* Kelly, Terence <1>: Persistent Memory. (line 138)
* Kelly, Terence <2>: Feature History. (line 510)
* Kenobi, Obi-Wan: Undocumented. (line 6)
* Kernighan, Brian: History. (line 21)
@@ -39286,7 +39277,7 @@ Index
* readfile() user-defined function: Readfile Function. (line 30)
* reading input files: Reading Files. (line 6)
* REALLY_USE_PERSIST_MALLOC environment variable: Persistent Memory.
- (line 29)
+ (line 28)
* recipe for a programming language: History. (line 6)
* record separators: awk split records. (line 6)
* record separators <1>: User-modified. (line 135)
@@ -40413,245 +40404,245 @@ Ref: Two-way I/O-Footnote-2938341
Node: TCP/IP Networking938423
Node: Profiling941591
Node: Persistent Memory951261
-Ref: Persistent Memory-Footnote-1961338
-Node: Extension Philosophy961469
-Node: Advanced Features Summary962996
-Node: Internationalization965262
-Node: I18N and L10N966964
-Node: Explaining gettext967659
-Ref: Explaining gettext-Footnote-1973795
-Ref: Explaining gettext-Footnote-2973988
-Node: Programmer i18n974153
-Ref: Programmer i18n-Footnote-1979265
-Node: Translator i18n979314
-Node: String Extraction980144
-Ref: String Extraction-Footnote-1981320
-Node: Printf Ordering981418
-Ref: Printf Ordering-Footnote-1984276
-Node: I18N Portability984344
-Ref: I18N Portability-Footnote-1986904
-Node: I18N Example986971
-Ref: I18N Example-Footnote-1990365
-Ref: I18N Example-Footnote-2990438
-Node: Gawk I18N990555
-Node: I18N Summary991209
-Node: Debugger992606
-Node: Debugging993626
-Node: Debugging Concepts994075
-Node: Debugging Terms995892
-Node: Awk Debugging998495
-Ref: Awk Debugging-Footnote-1999468
-Node: Sample Debugging Session999604
-Node: Debugger Invocation1000154
-Node: Finding The Bug1001779
-Node: List of Debugger Commands1008411
-Node: Breakpoint Control1009788
-Node: Debugger Execution Control1013610
-Node: Viewing And Changing Data1017084
-Node: Execution Stack1020818
-Node: Debugger Info1022499
-Node: Miscellaneous Debugger Commands1026794
-Node: Readline Support1032035
-Node: Limitations1032973
-Node: Debugging Summary1035597
-Node: Namespaces1036896
-Node: Global Namespace1038023
-Node: Qualified Names1039457
-Node: Default Namespace1040492
-Node: Changing The Namespace1041265
-Node: Naming Rules1042947
-Node: Internal Name Management1044902
-Node: Namespace Example1045972
-Node: Namespace And Features1048549
-Node: Namespace Summary1050004
-Node: Arbitrary Precision Arithmetic1051515
-Node: Computer Arithmetic1053034
-Ref: table-numeric-ranges1056959
-Ref: table-floating-point-ranges1057456
-Ref: Computer Arithmetic-Footnote-11058114
-Node: Math Definitions1058171
-Ref: table-ieee-formats1061203
-Node: MPFR features1061776
-Node: MPFR On Parole1062229
-Ref: MPFR On Parole-Footnote-11063070
-Node: MPFR Intro1063229
-Node: FP Math Caution1064914
-Ref: FP Math Caution-Footnote-11065986
-Node: Inexactness of computations1066360
-Node: Inexact representation1067391
-Node: Comparing FP Values1068772
-Node: Errors accumulate1070030
-Node: Strange values1071495
-Ref: Strange values-Footnote-11074149
-Node: Getting Accuracy1074254
-Node: Try To Round1076991
-Node: Setting precision1077898
-Ref: table-predefined-precision-strings1078603
-Node: Setting the rounding mode1080487
-Ref: table-gawk-rounding-modes1080869
-Ref: Setting the rounding mode-Footnote-11084921
-Node: Arbitrary Precision Integers1085106
-Ref: Arbitrary Precision Integers-Footnote-11088316
-Node: Checking for MPFR1088470
-Node: POSIX Floating Point Problems1089960
-Ref: POSIX Floating Point Problems-Footnote-11094780
-Node: Floating point summary1094818
-Node: Dynamic Extensions1097074
-Node: Extension Intro1098671
-Node: Plugin License1099973
-Node: Extension Mechanism Outline1100786
-Ref: figure-load-extension1101237
-Ref: figure-register-new-function1102815
-Ref: figure-call-new-function1103924
-Node: Extension API Description1106039
-Node: Extension API Functions Introduction1107768
-Ref: table-api-std-headers1109662
-Node: General Data Types1114103
-Ref: General Data Types-Footnote-11123249
-Node: Memory Allocation Functions1123552
-Ref: Memory Allocation Functions-Footnote-11128267
-Node: Constructor Functions1128366
-Node: API Ownership of MPFR and GMP Values1132267
-Node: Registration Functions1133820
-Node: Extension Functions1134524
-Node: Exit Callback Functions1140098
-Node: Extension Version String1141412
-Node: Input Parsers1142107
-Node: Output Wrappers1156726
-Node: Two-way processors1161568
-Node: Printing Messages1163921
-Ref: Printing Messages-Footnote-11165132
-Node: Updating ERRNO1165285
-Node: Requesting Values1166084
-Ref: table-value-types-returned1166837
-Node: Accessing Parameters1168896
-Node: Symbol Table Access1170177
-Node: Symbol table by name1170689
-Ref: Symbol table by name-Footnote-11173890
-Node: Symbol table by cookie1174022
-Ref: Symbol table by cookie-Footnote-11178291
-Node: Cached values1178355
-Ref: Cached values-Footnote-11181987
-Node: Array Manipulation1182144
-Ref: Array Manipulation-Footnote-11183243
-Node: Array Data Types1183280
-Ref: Array Data Types-Footnote-11186098
-Node: Array Functions1186194
-Node: Flattening Arrays1191223
-Node: Creating Arrays1198271
-Node: Redirection API1203113
-Node: Extension API Variables1206130
-Node: Extension Versioning1206853
-Ref: gawk-api-version1207282
-Node: Extension GMP/MPFR Versioning1209069
-Node: Extension API Informational Variables1210773
-Node: Extension API Boilerplate1212026
-Node: Changes from API V11216156
-Node: Finding Extensions1217788
-Node: Extension Example1218363
-Node: Internal File Description1219185
-Node: Internal File Ops1223477
-Ref: Internal File Ops-Footnote-11235027
-Node: Using Internal File Ops1235175
-Ref: Using Internal File Ops-Footnote-11237608
-Node: Extension Samples1237886
-Node: Extension Sample File Functions1239455
-Node: Extension Sample Fnmatch1247580
-Node: Extension Sample Fork1249175
-Node: Extension Sample Inplace1250451
-Node: Extension Sample Ord1254553
-Node: Extension Sample Readdir1255429
-Ref: table-readdir-file-types1256218
-Node: Extension Sample Revout1257574
-Node: Extension Sample Rev2way1258171
-Node: Extension Sample Read write array1258923
-Node: Extension Sample Readfile1262197
-Node: Extension Sample Time1263328
-Node: Extension Sample API Tests1265328
-Node: gawkextlib1265836
-Node: Extension summary1268869
-Node: Extension Exercises1272717
-Node: Language History1273987
-Node: V7/SVR3.11275699
-Node: SVR41278049
-Node: POSIX1279581
-Node: BTL1281006
-Node: POSIX/GNU1281773
-Ref: Gawk Extension Functions1285163
-Node: Feature History1288587
-Node: Common Extensions1308489
-Node: Ranges and Locales1309964
-Ref: Ranges and Locales-Footnote-11314749
-Ref: Ranges and Locales-Footnote-21314776
-Ref: Ranges and Locales-Footnote-31315011
-Node: Contributors1315234
-Node: History summary1321586
-Node: Installation1323028
-Node: Gawk Distribution1323992
-Node: Getting1324484
-Node: Extracting1325483
-Node: Distribution contents1327189
-Node: Unix Installation1335079
-Node: Quick Installation1335899
-Node: Compiling with MPFR1338439
-Node: Shell Startup Files1339145
-Node: Additional Configuration Options1340302
-Node: Configuration Philosophy1342685
-Node: Compiling from Git1345185
-Node: Building the Documentation1345746
-Node: Non-Unix Installation1347158
-Node: PC Installation1347634
-Node: PC Binary Installation1348503
-Node: PC Compiling1349396
-Node: PC Using1350574
-Node: Cygwin1354290
-Node: MSYS1355543
-Node: OpenVMS Installation1356169
-Node: OpenVMS Compilation1356850
-Ref: OpenVMS Compilation-Footnote-11358333
-Node: OpenVMS Dynamic Extensions1358391
-Node: OpenVMS Installation Details1360027
-Node: OpenVMS Running1362458
-Node: OpenVMS GNV1366595
-Node: Bugs1367350
-Node: Bug definition1368270
-Node: Bug address1371872
-Node: Usenet1375441
-Node: Performance bugs1376654
-Node: Asking for help1379658
-Node: Maintainers1381645
-Node: Other Versions1382672
-Node: Installation summary1392740
-Node: Notes1394122
-Node: Compatibility Mode1394932
-Node: Additions1395754
-Node: Accessing The Source1396699
-Node: Adding Code1398232
-Node: New Ports1405343
-Node: Derived Files1409846
-Ref: Derived Files-Footnote-11415657
-Ref: Derived Files-Footnote-21415692
-Ref: Derived Files-Footnote-31416303
-Node: Future Extensions1416417
-Node: Implementation Limitations1417087
-Node: Extension Design1418329
-Node: Old Extension Problems1419489
-Ref: Old Extension Problems-Footnote-11421061
-Node: Extension New Mechanism Goals1421122
-Ref: Extension New Mechanism Goals-Footnote-11424592
-Node: Extension Other Design Decisions1424793
-Node: Extension Future Growth1426990
-Node: Notes summary1427610
-Node: Basic Concepts1428820
-Node: Basic High Level1429505
-Ref: figure-general-flow1429787
-Ref: figure-process-flow1430489
-Ref: Basic High Level-Footnote-11433859
-Node: Basic Data Typing1434048
-Node: Glossary1437456
-Node: Copying1470338
-Node: GNU Free Documentation License1507896
-Node: Index1533019
+Ref: Persistent Memory-Footnote-1960701
+Node: Extension Philosophy960832
+Node: Advanced Features Summary962359
+Node: Internationalization964625
+Node: I18N and L10N966327
+Node: Explaining gettext967022
+Ref: Explaining gettext-Footnote-1973158
+Ref: Explaining gettext-Footnote-2973351
+Node: Programmer i18n973516
+Ref: Programmer i18n-Footnote-1978628
+Node: Translator i18n978677
+Node: String Extraction979507
+Ref: String Extraction-Footnote-1980683
+Node: Printf Ordering980781
+Ref: Printf Ordering-Footnote-1983639
+Node: I18N Portability983707
+Ref: I18N Portability-Footnote-1986267
+Node: I18N Example986334
+Ref: I18N Example-Footnote-1989728
+Ref: I18N Example-Footnote-2989801
+Node: Gawk I18N989918
+Node: I18N Summary990572
+Node: Debugger991969
+Node: Debugging992989
+Node: Debugging Concepts993438
+Node: Debugging Terms995255
+Node: Awk Debugging997858
+Ref: Awk Debugging-Footnote-1998831
+Node: Sample Debugging Session998967
+Node: Debugger Invocation999517
+Node: Finding The Bug1001142
+Node: List of Debugger Commands1007774
+Node: Breakpoint Control1009151
+Node: Debugger Execution Control1012973
+Node: Viewing And Changing Data1016447
+Node: Execution Stack1020181
+Node: Debugger Info1021862
+Node: Miscellaneous Debugger Commands1026157
+Node: Readline Support1031398
+Node: Limitations1032336
+Node: Debugging Summary1034960
+Node: Namespaces1036259
+Node: Global Namespace1037386
+Node: Qualified Names1038820
+Node: Default Namespace1039855
+Node: Changing The Namespace1040628
+Node: Naming Rules1042310
+Node: Internal Name Management1044265
+Node: Namespace Example1045335
+Node: Namespace And Features1047912
+Node: Namespace Summary1049367
+Node: Arbitrary Precision Arithmetic1050878
+Node: Computer Arithmetic1052397
+Ref: table-numeric-ranges1056322
+Ref: table-floating-point-ranges1056819
+Ref: Computer Arithmetic-Footnote-11057477
+Node: Math Definitions1057534
+Ref: table-ieee-formats1060566
+Node: MPFR features1061139
+Node: MPFR On Parole1061592
+Ref: MPFR On Parole-Footnote-11062433
+Node: MPFR Intro1062592
+Node: FP Math Caution1064277
+Ref: FP Math Caution-Footnote-11065349
+Node: Inexactness of computations1065723
+Node: Inexact representation1066754
+Node: Comparing FP Values1068135
+Node: Errors accumulate1069393
+Node: Strange values1070858
+Ref: Strange values-Footnote-11073512
+Node: Getting Accuracy1073617
+Node: Try To Round1076354
+Node: Setting precision1077261
+Ref: table-predefined-precision-strings1077966
+Node: Setting the rounding mode1079850
+Ref: table-gawk-rounding-modes1080232
+Ref: Setting the rounding mode-Footnote-11084284
+Node: Arbitrary Precision Integers1084469
+Ref: Arbitrary Precision Integers-Footnote-11087679
+Node: Checking for MPFR1087833
+Node: POSIX Floating Point Problems1089323
+Ref: POSIX Floating Point Problems-Footnote-11094143
+Node: Floating point summary1094181
+Node: Dynamic Extensions1096437
+Node: Extension Intro1098034
+Node: Plugin License1099336
+Node: Extension Mechanism Outline1100149
+Ref: figure-load-extension1100600
+Ref: figure-register-new-function1102178
+Ref: figure-call-new-function1103287
+Node: Extension API Description1105402
+Node: Extension API Functions Introduction1107131
+Ref: table-api-std-headers1109025
+Node: General Data Types1113466
+Ref: General Data Types-Footnote-11122612
+Node: Memory Allocation Functions1122915
+Ref: Memory Allocation Functions-Footnote-11127630
+Node: Constructor Functions1127729
+Node: API Ownership of MPFR and GMP Values1131630
+Node: Registration Functions1133183
+Node: Extension Functions1133887
+Node: Exit Callback Functions1139461
+Node: Extension Version String1140775
+Node: Input Parsers1141470
+Node: Output Wrappers1156089
+Node: Two-way processors1160931
+Node: Printing Messages1163284
+Ref: Printing Messages-Footnote-11164495
+Node: Updating ERRNO1164648
+Node: Requesting Values1165447
+Ref: table-value-types-returned1166200
+Node: Accessing Parameters1168259
+Node: Symbol Table Access1169540
+Node: Symbol table by name1170052
+Ref: Symbol table by name-Footnote-11173253
+Node: Symbol table by cookie1173385
+Ref: Symbol table by cookie-Footnote-11177654
+Node: Cached values1177718
+Ref: Cached values-Footnote-11181350
+Node: Array Manipulation1181507
+Ref: Array Manipulation-Footnote-11182606
+Node: Array Data Types1182643
+Ref: Array Data Types-Footnote-11185461
+Node: Array Functions1185557
+Node: Flattening Arrays1190586
+Node: Creating Arrays1197634
+Node: Redirection API1202476
+Node: Extension API Variables1205493
+Node: Extension Versioning1206216
+Ref: gawk-api-version1206645
+Node: Extension GMP/MPFR Versioning1208432
+Node: Extension API Informational Variables1210136
+Node: Extension API Boilerplate1211389
+Node: Changes from API V11215519
+Node: Finding Extensions1217151
+Node: Extension Example1217726
+Node: Internal File Description1218548
+Node: Internal File Ops1222840
+Ref: Internal File Ops-Footnote-11234390
+Node: Using Internal File Ops1234538
+Ref: Using Internal File Ops-Footnote-11236971
+Node: Extension Samples1237249
+Node: Extension Sample File Functions1238818
+Node: Extension Sample Fnmatch1246943
+Node: Extension Sample Fork1248538
+Node: Extension Sample Inplace1249814
+Node: Extension Sample Ord1253916
+Node: Extension Sample Readdir1254792
+Ref: table-readdir-file-types1255581
+Node: Extension Sample Revout1256937
+Node: Extension Sample Rev2way1257534
+Node: Extension Sample Read write array1258286
+Node: Extension Sample Readfile1261560
+Node: Extension Sample Time1262691
+Node: Extension Sample API Tests1264691
+Node: gawkextlib1265199
+Node: Extension summary1268232
+Node: Extension Exercises1272080
+Node: Language History1273350
+Node: V7/SVR3.11275062
+Node: SVR41277412
+Node: POSIX1278944
+Node: BTL1280369
+Node: POSIX/GNU1281136
+Ref: Gawk Extension Functions1284526
+Node: Feature History1287950
+Node: Common Extensions1307852
+Node: Ranges and Locales1309327
+Ref: Ranges and Locales-Footnote-11314112
+Ref: Ranges and Locales-Footnote-21314139
+Ref: Ranges and Locales-Footnote-31314374
+Node: Contributors1314597
+Node: History summary1320949
+Node: Installation1322391
+Node: Gawk Distribution1323355
+Node: Getting1323847
+Node: Extracting1324846
+Node: Distribution contents1326552
+Node: Unix Installation1334442
+Node: Quick Installation1335262
+Node: Compiling with MPFR1337802
+Node: Shell Startup Files1338508
+Node: Additional Configuration Options1339665
+Node: Configuration Philosophy1342048
+Node: Compiling from Git1344548
+Node: Building the Documentation1345109
+Node: Non-Unix Installation1346521
+Node: PC Installation1346997
+Node: PC Binary Installation1347866
+Node: PC Compiling1348759
+Node: PC Using1349937
+Node: Cygwin1353653
+Node: MSYS1354906
+Node: OpenVMS Installation1355532
+Node: OpenVMS Compilation1356213
+Ref: OpenVMS Compilation-Footnote-11357696
+Node: OpenVMS Dynamic Extensions1357754
+Node: OpenVMS Installation Details1359390
+Node: OpenVMS Running1361821
+Node: OpenVMS GNV1365958
+Node: Bugs1366713
+Node: Bug definition1367633
+Node: Bug address1371235
+Node: Usenet1374804
+Node: Performance bugs1376017
+Node: Asking for help1379021
+Node: Maintainers1381008
+Node: Other Versions1382035
+Node: Installation summary1392103
+Node: Notes1393485
+Node: Compatibility Mode1394295
+Node: Additions1395117
+Node: Accessing The Source1396062
+Node: Adding Code1397595
+Node: New Ports1404706
+Node: Derived Files1409209
+Ref: Derived Files-Footnote-11415020
+Ref: Derived Files-Footnote-21415055
+Ref: Derived Files-Footnote-31415666
+Node: Future Extensions1415780
+Node: Implementation Limitations1416450
+Node: Extension Design1417692
+Node: Old Extension Problems1418852
+Ref: Old Extension Problems-Footnote-11420424
+Node: Extension New Mechanism Goals1420485
+Ref: Extension New Mechanism Goals-Footnote-11423955
+Node: Extension Other Design Decisions1424156
+Node: Extension Future Growth1426353
+Node: Notes summary1426973
+Node: Basic Concepts1428183
+Node: Basic High Level1428868
+Ref: figure-general-flow1429150
+Ref: figure-process-flow1429852
+Ref: Basic High Level-Footnote-11433222
+Node: Basic Data Typing1433411
+Node: Glossary1436819
+Node: Copying1469701
+Node: GNU Free Documentation License1507259
+Node: Index1532382
End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index dc045cdf..34c7a837 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -30690,12 +30690,11 @@ in a persistent heap, which resides in a file in
the filesystem. When persistent memory is not in use (the normal case),
@command{gawk}'s data resides in ephemeral system memory.
-Persistent memory is enabled on certain 64-bit systems supporting the
@code{mmap()}
-and @code{munmap()} system calls. @command{gawk} must be compiled as a
-non-PIE (Position Independent Executable) binary, since the persistent
+Persistent memory is enabled on certain 64-bit systems supporting the
+@code{mmap()} and @code{munmap()} system calls. Since the persistent
store ends up holding pointers to functions held within the @command{gawk}
-executable. This also means that to use the persistent memory, you must
-use the same @command{gawk} executable from run to run.
+executable, in order to use persistent memory, you must use the same
+@command{gawk} executable from run to run.
You can see if your version of @command{gawk} supports persistent
memory like so:
@@ -30713,7 +30712,7 @@ If you see the @samp{PMA} with a version indicator,
then it's supported.
@cindex @env{REALLY_USE_PERSIST_MALLOC} environment variable
@cindex environment variables @subentry @env{REALLY_USE_PERSIST_MALLOC}
As of this writing, persistent memory has only been tested on GNU/Linux,
-Cygwin, Solaris 2.11, Intel architecture macOS systems,
+Cygwin, Solaris 2.11, macOS,
FreeBSD 13.1 and OpenBSD 7.1.
On all others, persistent memory is disabled by default. You can force
it to be enabled by exporting the shell variable
@@ -30768,13 +30767,12 @@ As shown, in subsequent runs using the same data
file, the values of
@command{gawk}'s variables are preserved. However, @command{gawk}'s
special variables, such as @code{NR}, are reset upon each run.
Only the variables defined by the program are preserved across runs.
-
@end enumerate
-Interestingly, the program that you execute need not be the same from
+Interestingly, the @command{awk} program that you execute need not be the same
from
run to run; the persistent store only maintains the values of variables,
arrays, and user-defined functions, not the totality of @command{gawk}'s
-internal state. This lets you share data between unrelated programs,
+internal state. This lets you share data between unrelated @command{awk}
programs,
eliminating the need for scripts to communicate via text files.
@cindex Kelly, Terence
@@ -30834,16 +30832,6 @@ The GNU/Linux CIFS filesystem is known to not
work well with the PMA allocator.
Don't use a backing file on a CIFS filesystem.
-@item
-Some GNU/Linux distributions enable Address Space Layout Randomization
-(ASLR) by default. This breaks @command{gawk}'s use of the PMA allocator.
-You can work around this using @samp{setarch -R gawk @dots{}} to run
-@command{gawk}; this disables ASLR for the particular execution of
-@command{gawk}. If ASLR is the default on your system, and you want to use
-persistent memory, you may wish to set up a shell alias, shell function,
-or shell script to run @command{gawk} by way of the @command{setarch}
-command.
-
@item
If @command{gawk} is run by the @command{root} user, then
persistent memory is not allowed. This is to avoid the possibility
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=6749e9972375566e820d14081b5b79189f8a0d16
commit 6749e9972375566e820d14081b5b79189f8a0d16
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Sat Feb 1 19:37:49 2025 +0200
Typo fix in posix/gawkmisc.c.
diff --git a/posix/gawkmisc.c b/posix/gawkmisc.c
index a089d18c..9a5c9a46 100644
--- a/posix/gawkmisc.c
+++ b/posix/gawkmisc.c
@@ -370,7 +370,7 @@ os_disable_aslr(const char *persist_file, char **argv)
exit(EXIT_FATAL);
}
} else {
- fprintf(stderr, _("fatal: posix_spawn: %s\n"),
sterror(errno));
+ fprintf(stderr, _("fatal: posix_spawn: %s\n"),
strerror(errno));
exit(EXIT_FATAL);
}
} else
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=90f6c3ed3e41e881f624fb805d2321eb80122357
commit 90f6c3ed3e41e881f624fb805d2321eb80122357
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Sat Feb 1 19:32:05 2025 +0200
Add code for macos so don't need -no-pie.
diff --git a/ChangeLog b/ChangeLog
index 65a3d881..a27d28d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-02-05 Arnold D. Robbins <arnold@skeeve.com>
+
+ * configure.ac: Add checks for spawn.h and _NSGetExecutablePath
+ function.
+ * awk.h (os_disable_aslr): Add function declaration.
+ * main.c (enable_pma): Move OS specific code out of this function
+ and in posix/gawkmisc.c. Instead, call os_disable_aslr().
+
2025-02-05 Arnold D. Robbins <arnold@skeeve.com>
* main.c (enable_pma): Remove unused argc parameter and adjust
diff --git a/awk.h b/awk.h
index 8741dbe9..761f3af8 100644
--- a/awk.h
+++ b/awk.h
@@ -1640,6 +1640,7 @@ extern int os_is_setuid(void);
extern int os_setbinmode(int fd, int mode);
extern void os_restore_mode(int fd);
extern void os_maybe_set_errno(void);
+extern void os_disable_aslr(const char *persist_file, char **argv);
extern size_t optimal_bufsize(int fd, struct stat *sbuf);
extern int ispath(const char *file);
extern int isdirpunct(int c);
diff --git a/configh.in b/configh.in
index 306f7b9d..885c4b91 100644
--- a/configh.in
+++ b/configh.in
@@ -204,6 +204,9 @@
/* we have sockets on this system */
#undef HAVE_SOCKETS
+/* Define to 1 if you have the <spawn.h> header file. */
+#undef HAVE_SPAWN_H
+
/* Define to 1 if you have the <stdbool.h> header file. */
#undef HAVE_STDBOOL_H
@@ -362,6 +365,9 @@
/* systems should define this type here */
#undef HAVE_WINT_T
+/* Define to 1 if you have the `_NSGetExecutablePath' function. */
+#undef HAVE__NSGETEXECUTABLEPATH
+
/* Define to 1 if you have the `__etoa_l' function. */
#undef HAVE___ETOA_L
diff --git a/configure b/configure
index 29cb8b8d..2c2e2b03 100755
--- a/configure
+++ b/configure
@@ -10306,6 +10306,12 @@ if test "x$ac_cv_header_string_h" = xyes
then :
printf "%s\n" "#define HAVE_STRING_H 1" >>confdefs.h
+fi
+ac_fn_c_check_header_compile "$LINENO" "spawn.h" "ac_cv_header_spawn_h"
"$ac_includes_default"
+if test "x$ac_cv_header_spawn_h" = xyes
+then :
+ printf "%s\n" "#define HAVE_SPAWN_H 1" >>confdefs.h
+
fi
ac_fn_c_check_header_compile "$LINENO" "sys/ioctl.h"
"ac_cv_header_sys_ioctl_h" "$ac_includes_default"
if test "x$ac_cv_header_sys_ioctl_h" = xyes
@@ -11720,6 +11726,12 @@ if test "x$ac_cv_func_memset" = xyes
then :
printf "%s\n" "#define HAVE_MEMSET 1" >>confdefs.h
+fi
+ac_fn_c_check_func "$LINENO" "_NSGetExecutablePath"
"ac_cv_func__NSGetExecutablePath"
+if test "x$ac_cv_func__NSGetExecutablePath" = xyes
+then :
+ printf "%s\n" "#define HAVE__NSGETEXECUTABLEPATH 1" >>confdefs.h
+
fi
ac_fn_c_check_func "$LINENO" "mkstemp" "ac_cv_func_mkstemp"
if test "x$ac_cv_func_mkstemp" = xyes
@@ -12032,17 +12044,7 @@ fi
true # On Linux we no longer need -no-pie
;;
*darwin*)
- # 27 November 2022: PMA only works on Intel.
- case $host in
- x86_64-*)
- LDFLAGS="${LDFLAGS} -Xlinker -no_pie"
- export LDFLAGS
- ;;
- *)
- # disable on all other macOS systems
- use_persistent_malloc=no
- ;;
- esac
+ true # On macos we no longer need -no-pie
;;
*cygwin* | *CYGWIN* | *solaris2.11* | freebsd13.* | openbsd7.* )
true # nothing to do, exes on these systems are not
PIE
diff --git a/configure.ac b/configure.ac
index 6570aa5b..015e18ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,6 +187,7 @@ gt_LC_MESSAGES
dnl checks for header files
AC_CHECK_HEADERS(arpa/inet.h fcntl.h locale.h libintl.h mcheck.h \
netdb.h netinet/in.h stddef.h string.h \
+ spawn.h \
sys/ioctl.h sys/param.h sys/personality.h sys/select.h sys/socket.h
sys/time.h \
unistd.h termios.h stropts.h wchar.h wctype.h)
@@ -317,6 +318,7 @@ AC_CHECK_FUNCS(__etoa_l atexit btowc fmod fwrite_unlocked
gai_strerror \
gettimeofday clock_gettime lstat \
getdtablesize \
mbrlen memcmp memcpy memmove memset \
+ _NSGetExecutablePath \
mkstemp mtrace personality posix_openpt setenv setlocale setsid
sigprocmask \
snprintf strcasecmp strchr strcoll strerror strftime strncasecmp \
strsignal strtod strtoul system timegm tmpfile towlower towupper \
diff --git a/m4/ChangeLog b/m4/ChangeLog
index bab71faf..8498a9ac 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,8 @@
+2025-02-01 Arnold D. Robbins <arnold@skeeve.com>
+
+ * pma.m4: On macos, no longer need to do anything special,
+ but we do have to have a case for it so that PMA is enabled.
+
2025-01-29 Arnold D. Robbins <arnold@skeeve.com>
* pma.m4: On Linux, no longer need to do anything special,
diff --git a/m4/pma.m4 b/m4/pma.m4
index 6bc67a0d..f270f4f3 100644
--- a/m4/pma.m4
+++ b/m4/pma.m4
@@ -22,17 +22,7 @@ then
true # On Linux we no longer need -no-pie
;;
*darwin*)
- # 27 November 2022: PMA only works on Intel.
- case $host in
- x86_64-*)
- LDFLAGS="${LDFLAGS} -Xlinker -no_pie"
- export LDFLAGS
- ;;
- *)
- # disable on all other macOS systems
- use_persistent_malloc=no
- ;;
- esac
+ true # On macos we no longer need -no-pie
;;
*cygwin* | *CYGWIN* | *solaris2.11* | freebsd13.* | openbsd7.* )
true # nothing to do, exes on these systems are not
PIE
diff --git a/main.c b/main.c
index ebccf43f..191e2b6a 100644
--- a/main.c
+++ b/main.c
@@ -34,10 +34,6 @@
#include <mcheck.h>
#endif
-#ifdef HAVE_SYS_PERSONALITY_H
-#include <sys/personality.h>
-#endif
-
#define DEFAULT_PROFILE "awkprof.out" /* where to put profile
*/
#define DEFAULT_VARFILE "awkvars.out" /* where to put vars */
#define DEFAULT_PREC 53
@@ -1916,6 +1912,8 @@ check_pma_security(const char *pma_file)
#endif /* USE_PERSISTENT_MALLOC */
}
+//#include <libproc.h>
+#include <spawn.h>
/* enable_pma --- do the PMA flow, handle ASLR on Linux */
@@ -1930,35 +1928,7 @@ enable_pma(char **argv)
return false;
}
#else
-#ifdef HAVE_PERSONALITY
- // This code is Linux specific, both the reliance on /proc/self/exe
- // and the personality system call.
- if (persist_file != NULL) {
- const char *cp = getenv("GAWK_PMA_REINCARNATION");
-
- if (cp == NULL) {
- char fullpath[BUFSIZ];
- int n;
-
- if ((n = readlink("/proc/self/exe", fullpath,
sizeof(fullpath)-1)) < 0) {
- fprintf(stderr, _("warning: /proc/self/exe:
readlink: %s\n"),
- strerror(errno));
- goto init;
- }
- fullpath[n] = '\0';
- putenv("GAWK_PMA_REINCARNATION=true");
- if (personality(PER_LINUX | ADDR_NO_RANDOMIZE) < 0) {
- fprintf(stderr, _("warning: personality: %s\n"),
- strerror(errno));
- fflush(stderr);
- // do the exec anyway...
- }
- execv(fullpath, argv);
- } else
- (void) unsetenv("GAWK_PMA_REINCARNATION");
- }
-init:
-#endif /* HAVE_PERSONALITY */
+ os_disable_aslr(persist_file, argv);
check_pma_security(persist_file);
int pma_result = pma_init(1, persist_file);
diff --git a/posix/ChangeLog b/posix/ChangeLog
index 28f74e96..09247343 100644
--- a/posix/ChangeLog
+++ b/posix/ChangeLog
@@ -1,3 +1,7 @@
+2025-02-01 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawkmisc.c (os_disable_aslr): New function for *nix.
+
2024-09-17 Arnold D. Robbins <arnold@skeeve.com>
* 5.3.1: Release tar made.
diff --git a/posix/gawkmisc.c b/posix/gawkmisc.c
index 0b30d746..a089d18c 100644
--- a/posix/gawkmisc.c
+++ b/posix/gawkmisc.c
@@ -1,6 +1,7 @@
/* gawkmisc.c --- miscellaneous gawk routines that are OS specific.
- Copyright (C) 1986, 1988, 1989, 1991 - 1998, 2001 - 2004, 2011, 2021, 2022,
2023,
+ Copyright (C) 1986, 1988, 1989, 1991 - 1998, 2001 - 2004, 2011,
+ 2021, 2022, 2023, 2025,
the Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -26,6 +27,14 @@
#include <io.h> /* for declaration of setmode(). */
#endif
+#ifdef HAVE_SYS_PERSONALITY_H // for linux
+#include <sys/personality.h>
+#endif
+
+#ifdef HAVE_SPAWN_H
+#include <spawn.h> // for macos
+#endif
+
const char quote = '\'';
const char *defpath = DEFPATH;
const char *deflibpath = DEFLIBPATH;
@@ -297,6 +306,81 @@ os_maybe_set_errno(void)
{
}
+/* os_disable_aslr --- disable Address Space Layout Randomization */
+
+void
+os_disable_aslr(const char *persist_file, char **argv)
+{
+#ifdef HAVE_PERSONALITY
+ // This code is Linux specific, both the reliance on /proc/self/exe
+ // and the personality system call.
+ if (persist_file != NULL) {
+ const char *cp = getenv("GAWK_PMA_REINCARNATION");
+
+ if (cp == NULL) {
+ char fullpath[BUFSIZ];
+ int n;
+
+ if ((n = readlink("/proc/self/exe", fullpath,
sizeof(fullpath)-1)) < 0) {
+ fprintf(stderr, _("warning: /proc/self/exe:
readlink: %s\n"),
+ strerror(errno));
+ return;
+ }
+ fullpath[n] = '\0';
+ putenv("GAWK_PMA_REINCARNATION=true");
+ if (personality(PER_LINUX | ADDR_NO_RANDOMIZE) < 0) {
+ fprintf(stderr, _("warning: personality: %s\n"),
+ strerror(errno));
+ fflush(stderr);
+ // do the exec anyway...
+ }
+ execv(fullpath, argv);
+ } else
+ (void) unsetenv("GAWK_PMA_REINCARNATION");
+ }
+#endif
+#ifdef HAVE__NSGETEXECUTABLEPATH
+ // This code is for macos
+ if (persist_file != NULL) {
+ const char *cp = getenv("GAWK_PMA_REINCARNATION");
+
+ if (cp == NULL) {
+ char fullpath[BUFSIZ];
+ int n;
+ posix_spawnattr_t p_attr;
+ int status;
+ pid_t pid;
+ extern char **environ;
+ size_t size = BUFSIZ;
+
+ memset(fullpath, 0, BUFSIZ);
+ n = _NSGetExecutablePath(fullpath, &size);
+
+ putenv("GAWK_PMA_REINCARNATION=true");
+
+ posix_spawnattr_init(&p_attr);
+ posix_spawnattr_setflags(&p_attr, 0x100);
+ status = posix_spawnp(&pid, fullpath, NULL, &p_attr,
argv, environ);
+ if (status == 0) {
+ if (waitpid(pid, &status, WUNTRACED) != -1) {
+ if (WIFEXITED(status))
+ exit WEXITSTATUS(status);
// use original exit code
+ } else {
+ fprintf(stderr, _("waitpid: got exit
status %#o\n"), status);
+ exit(EXIT_FATAL);
+ }
+ } else {
+ fprintf(stderr, _("fatal: posix_spawn: %s\n"),
sterror(errno));
+ exit(EXIT_FATAL);
+ }
+ } else
+ (void) unsetenv("GAWK_PMA_REINCARNATION");
+ }
+#endif
+}
+
+// This for Linux and MacOS. It's not needed on other *nix systems.
+
// For MSYS, restore behavior of working in text mode.
#ifdef __MSYS__
void
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=031f662150a46933f856b42d586741cf42dea4c3
commit 031f662150a46933f856b42d586741cf42dea4c3
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Thu Jan 30 19:50:23 2025 +0200
Small improvements in the PMA flow.
diff --git a/ChangeLog b/ChangeLog
index 4f88187e..65a3d881 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-02-05 Arnold D. Robbins <arnold@skeeve.com>
+
+ * main.c (enable_pma): Remove unused argc parameter and adjust
+ call. Add call to unsetenv() for magic env var if it was
+ there, so that the environment is as it was before the exec.
+
2025-02-05 Arnold D. Robbins <arnold@skeeve.com>
* main.c (enable_pma): New function. Has the entire init flow
diff --git a/main.c b/main.c
index 33b10d6b..ebccf43f 100644
--- a/main.c
+++ b/main.c
@@ -147,7 +147,7 @@ static const char *locale_dir = LOCALEDIR; /* default
locale dir */
#ifdef USE_PERSISTENT_MALLOC
const char *get_pma_version(void);
#endif
-static bool enable_pma(int argc, char **argv);
+static bool enable_pma(char **argv);
int use_lc_numeric = false; /* obey locale for decimal point */
@@ -224,7 +224,7 @@ main(int argc, char **argv)
myname = gawk_name(argv[0]);
- using_persistent_malloc = enable_pma(argc, argv);
+ using_persistent_malloc = enable_pma(argv);
#ifdef HAVE_MPFR
mp_set_memory_functions(mpfr_mem_alloc, mpfr_mem_realloc,
mpfr_mem_free);
#endif
@@ -1920,7 +1920,7 @@ check_pma_security(const char *pma_file)
/* enable_pma --- do the PMA flow, handle ASLR on Linux */
static bool
-enable_pma(int argc, char **argv)
+enable_pma(char **argv)
{
const char *persist_file = getenv("GAWK_PERSIST_FILE"); /* backing file
for PMA */
@@ -1954,7 +1954,8 @@ enable_pma(int argc, char **argv)
// do the exec anyway...
}
execv(fullpath, argv);
- }
+ } else
+ (void) unsetenv("GAWK_PMA_REINCARNATION");
}
init:
#endif /* HAVE_PERSONALITY */
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=4123430172a2119cd99a3f5211917d7f4edb4f3f
commit 4123430172a2119cd99a3f5211917d7f4edb4f3f
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Wed Jan 29 20:26:28 2025 +0200
On Linux, enable PMA even for PIE executables.
diff --git a/ChangeLog b/ChangeLog
index 7d4a69cd..4f88187e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-02-05 Arnold D. Robbins <arnold@skeeve.com>
+
+ * main.c (enable_pma): New function. Has the entire init flow
+ for PMA. Also has new linux-specific code to deal with being
+ an PIE executable.
+ (main): Call enable_pma().
+ * configure.ac: Add checks for <sys/personality.h> and the
+ personality() system call.
+ * NEWS: Updated.
+
2025-02-05 Arnold D. Robbins <arnold@skeeve.com>
Stylistic cleanups and small code cleanups.
diff --git a/NEWS b/NEWS
index a02a9904..2eb6d5a5 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,8 @@ Changes from 5.3.1 to 5.3.x
2. OpenVMS 9.2-2 x86_64 is now supported.
+3. On Linux systems, the -no-pie linker flag is no longer required.
+
XX. As usual, there have been several minor code cleanups and bug fixes.
See the ChangeLog for details.
diff --git a/configh.in b/configh.in
index c3465c6e..306f7b9d 100644
--- a/configh.in
+++ b/configh.in
@@ -177,6 +177,9 @@
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
+/* Define to 1 if you have the `personality' function. */
+#undef HAVE_PERSONALITY
+
/* Define to 1 if you have the `posix_openpt' function. */
#undef HAVE_POSIX_OPENPT
@@ -276,6 +279,9 @@
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
+/* Define to 1 if you have the <sys/personality.h> header file. */
+#undef HAVE_SYS_PERSONALITY_H
+
/* Define to 1 if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
diff --git a/configure b/configure
index 694f0ea9..29cb8b8d 100755
--- a/configure
+++ b/configure
@@ -10318,6 +10318,12 @@ if test "x$ac_cv_header_sys_param_h" = xyes
then :
printf "%s\n" "#define HAVE_SYS_PARAM_H 1" >>confdefs.h
+fi
+ac_fn_c_check_header_compile "$LINENO" "sys/personality.h"
"ac_cv_header_sys_personality_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_personality_h" = xyes
+then :
+ printf "%s\n" "#define HAVE_SYS_PERSONALITY_H 1" >>confdefs.h
+
fi
ac_fn_c_check_header_compile "$LINENO" "sys/select.h"
"ac_cv_header_sys_select_h" "$ac_includes_default"
if test "x$ac_cv_header_sys_select_h" = xyes
@@ -11726,6 +11732,12 @@ if test "x$ac_cv_func_mtrace" = xyes
then :
printf "%s\n" "#define HAVE_MTRACE 1" >>confdefs.h
+fi
+ac_fn_c_check_func "$LINENO" "personality" "ac_cv_func_personality"
+if test "x$ac_cv_func_personality" = xyes
+then :
+ printf "%s\n" "#define HAVE_PERSONALITY 1" >>confdefs.h
+
fi
ac_fn_c_check_func "$LINENO" "posix_openpt" "ac_cv_func_posix_openpt"
if test "x$ac_cv_func_posix_openpt" = xyes
@@ -12017,45 +12029,7 @@ fi
use_persistent_malloc=yes
case $host_os in
linux-*)
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking
whether C compiler accepts -no-pie" >&5
-printf %s "checking whether C compiler accepts -no-pie... " >&6; }
-if test ${ax_cv_check_cflags___no_pie+y}
-then :
- printf %s "(cached) " >&6
-else $as_nop
-
- ax_check_save_flags=$CFLAGS
- CFLAGS="$CFLAGS -no-pie"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main (void)
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
- ax_cv_check_cflags___no_pie=yes
-else $as_nop
- ax_cv_check_cflags___no_pie=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
- CFLAGS=$ax_check_save_flags
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result:
$ax_cv_check_cflags___no_pie" >&5
-printf "%s\n" "$ax_cv_check_cflags___no_pie" >&6; }
-if test "x$ax_cv_check_cflags___no_pie" = xyes
-then :
- LDFLAGS="${LDFLAGS} -no-pie"
- export LDFLAGS
-else $as_nop
- :
-fi
-
+ true # On Linux we no longer need -no-pie
;;
*darwin*)
# 27 November 2022: PMA only works on Intel.
@@ -12071,7 +12045,7 @@ fi
esac
;;
*cygwin* | *CYGWIN* | *solaris2.11* | freebsd13.* | openbsd7.* )
- true # nothing do, exes on these systems are not PIE
+ true # nothing to do, exes on these systems are not
PIE
;;
# Other OS's go here...
*)
diff --git a/configure.ac b/configure.ac
index 679504de..6570aa5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,8 +187,8 @@ gt_LC_MESSAGES
dnl checks for header files
AC_CHECK_HEADERS(arpa/inet.h fcntl.h locale.h libintl.h mcheck.h \
netdb.h netinet/in.h stddef.h string.h \
- sys/ioctl.h sys/param.h sys/select.h sys/socket.h sys/time.h unistd.h \
- termios.h stropts.h wchar.h wctype.h)
+ sys/ioctl.h sys/param.h sys/personality.h sys/select.h sys/socket.h
sys/time.h \
+ unistd.h termios.h stropts.h wchar.h wctype.h)
gl_C_BOOL
AC_HEADER_SYS_WAIT
@@ -317,7 +317,7 @@ AC_CHECK_FUNCS(__etoa_l atexit btowc fmod fwrite_unlocked
gai_strerror \
gettimeofday clock_gettime lstat \
getdtablesize \
mbrlen memcmp memcpy memmove memset \
- mkstemp mtrace posix_openpt setenv setlocale setsid sigprocmask \
+ mkstemp mtrace personality posix_openpt setenv setlocale setsid
sigprocmask \
snprintf strcasecmp strchr strcoll strerror strftime strncasecmp \
strsignal strtod strtoul system timegm tmpfile towlower towupper \
tzset usleep waitpid wcrtomb wcscoll wctype)
diff --git a/extension/configure b/extension/configure
index e86d7ab1..45aac712 100755
--- a/extension/configure
+++ b/extension/configure
@@ -8792,45 +8792,7 @@ fi
use_persistent_malloc=yes
case $host_os in
linux-*)
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking
whether C compiler accepts -no-pie" >&5
-printf %s "checking whether C compiler accepts -no-pie... " >&6; }
-if test ${ax_cv_check_cflags___no_pie+y}
-then :
- printf %s "(cached) " >&6
-else $as_nop
-
- ax_check_save_flags=$CFLAGS
- CFLAGS="$CFLAGS -no-pie"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main (void)
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
- ax_cv_check_cflags___no_pie=yes
-else $as_nop
- ax_cv_check_cflags___no_pie=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
- CFLAGS=$ax_check_save_flags
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result:
$ax_cv_check_cflags___no_pie" >&5
-printf "%s\n" "$ax_cv_check_cflags___no_pie" >&6; }
-if test "x$ax_cv_check_cflags___no_pie" = xyes
-then :
- LDFLAGS="${LDFLAGS} -no-pie"
- export LDFLAGS
-else $as_nop
- :
-fi
-
+ true # On Linux we no longer need -no-pie
;;
*darwin*)
# 27 November 2022: PMA only works on Intel.
@@ -8846,7 +8808,7 @@ fi
esac
;;
*cygwin* | *CYGWIN* | *solaris2.11* | freebsd13.* | openbsd7.* )
- true # nothing do, exes on these systems are not PIE
+ true # nothing to do, exes on these systems are not
PIE
;;
# Other OS's go here...
*)
diff --git a/m4/ChangeLog b/m4/ChangeLog
index f81f8504..bab71faf 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,8 @@
+2025-01-29 Arnold D. Robbins <arnold@skeeve.com>
+
+ * pma.m4: On Linux, no longer need to do anything special,
+ but we do have to have a case for it so that PMA is enabled.
+
2024-09-17 Arnold D. Robbins <arnold@skeeve.com>
* 5.3.1: Release tar made.
diff --git a/m4/pma.m4 b/m4/pma.m4
index 6b7c6ed8..6bc67a0d 100644
--- a/m4/pma.m4
+++ b/m4/pma.m4
@@ -1,6 +1,6 @@
dnl Decide whether or not to use the persistent memory allocator
dnl
-dnl Copyright (C) 2022, 2023 Free Software Foundation, Inc.
+dnl Copyright (C) 2022, 2023, 2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -19,9 +19,7 @@ then
use_persistent_malloc=yes
case $host_os in
linux-*)
- AX_CHECK_COMPILE_FLAG([-no-pie],
- [LDFLAGS="${LDFLAGS} -no-pie"
- export LDFLAGS])
+ true # On Linux we no longer need -no-pie
;;
*darwin*)
# 27 November 2022: PMA only works on Intel.
@@ -37,7 +35,7 @@ then
esac
;;
*cygwin* | *CYGWIN* | *solaris2.11* | freebsd13.* | openbsd7.* )
- true # nothing do, exes on these systems are not PIE
+ true # nothing to do, exes on these systems are not
PIE
;;
# Other OS's go here...
*)
diff --git a/main.c b/main.c
index e50b1890..33b10d6b 100644
--- a/main.c
+++ b/main.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-2024,
+ * Copyright (C) 1986, 1988, 1989, 1991-2025,
* the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
@@ -34,6 +34,10 @@
#include <mcheck.h>
#endif
+#ifdef HAVE_SYS_PERSONALITY_H
+#include <sys/personality.h>
+#endif
+
#define DEFAULT_PROFILE "awkprof.out" /* where to put profile
*/
#define DEFAULT_VARFILE "awkvars.out" /* where to put vars */
#define DEFAULT_PREC 53
@@ -143,6 +147,7 @@ static const char *locale_dir = LOCALEDIR; /* default
locale dir */
#ifdef USE_PERSISTENT_MALLOC
const char *get_pma_version(void);
#endif
+static bool enable_pma(int argc, char **argv);
int use_lc_numeric = false; /* obey locale for decimal point */
@@ -213,28 +218,13 @@ main(int argc, char **argv)
bool have_srcfile = false;
SRCFILE *s;
char *cp;
- const char *persist_file = getenv("GAWK_PERSIST_FILE"); /* backing file
for PMA */
#if defined(LOCALEDEBUG)
const char *initial_locale;
#endif
myname = gawk_name(argv[0]);
- check_pma_security(persist_file);
-
- int pma_result = pma_init(1, persist_file);
- if (pma_result != 0) {
- // don't use 'fatal' routine, memory can't be allocated
- fprintf(stderr, _("%s: fatal: persistent memory allocator
failed to initialize: return value %d, pma.c line: %d.\n"),
- myname, pma_result, pma_errno);
- exit(EXIT_FATAL);
- }
-
- using_persistent_malloc = (persist_file != NULL);
-#ifndef USE_PERSISTENT_MALLOC
- if (using_persistent_malloc)
- warning(_("persistent memory is not supported"));
-#endif
+ using_persistent_malloc = enable_pma(argc, argv);
#ifdef HAVE_MPFR
mp_set_memory_functions(mpfr_mem_alloc, mpfr_mem_realloc,
mpfr_mem_free);
#endif
@@ -1925,3 +1915,60 @@ check_pma_security(const char *pma_file)
}
#endif /* USE_PERSISTENT_MALLOC */
}
+
+
+/* enable_pma --- do the PMA flow, handle ASLR on Linux */
+
+static bool
+enable_pma(int argc, char **argv)
+{
+ const char *persist_file = getenv("GAWK_PERSIST_FILE"); /* backing file
for PMA */
+
+#ifndef USE_PERSISTENT_MALLOC
+ if (persist_file != NULL) {
+ warning(_("persistent memory is not supported"));
+ return false;
+ }
+#else
+#ifdef HAVE_PERSONALITY
+ // This code is Linux specific, both the reliance on /proc/self/exe
+ // and the personality system call.
+ if (persist_file != NULL) {
+ const char *cp = getenv("GAWK_PMA_REINCARNATION");
+
+ if (cp == NULL) {
+ char fullpath[BUFSIZ];
+ int n;
+
+ if ((n = readlink("/proc/self/exe", fullpath,
sizeof(fullpath)-1)) < 0) {
+ fprintf(stderr, _("warning: /proc/self/exe:
readlink: %s\n"),
+ strerror(errno));
+ goto init;
+ }
+ fullpath[n] = '\0';
+ putenv("GAWK_PMA_REINCARNATION=true");
+ if (personality(PER_LINUX | ADDR_NO_RANDOMIZE) < 0) {
+ fprintf(stderr, _("warning: personality: %s\n"),
+ strerror(errno));
+ fflush(stderr);
+ // do the exec anyway...
+ }
+ execv(fullpath, argv);
+ }
+ }
+init:
+#endif /* HAVE_PERSONALITY */
+
+ check_pma_security(persist_file);
+ int pma_result = pma_init(1, persist_file);
+ if (pma_result != 0) {
+ // don't use 'fatal' routine, memory can't be allocated
+ fprintf(stderr, _("%s: fatal: persistent memory allocator
failed to initialize: return value %d, pma.c line: %d.\n"),
+ myname, pma_result, pma_errno);
+ exit(EXIT_FATAL);
+ }
+
+
+ return (persist_file != NULL);
+#endif
+}
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 71 +++++++++++++++++++++++++++++--
array.c | 64 ++++++++++++++++++++++++----
awk.h | 16 ++++++-
builtin.c | 22 ++++++++--
eval.c | 23 ++++++++++
ext.c | 5 +++
field.c | 17 ++++++--
gawkapi.c | 7 ++-
interpret.h | 14 +++++-
mpfr.c | 1 +
node.c | 7 +++
pc/ChangeLog | 4 ++
pc/Makefile.tst | 39 ++++++++++++++++-
test/ChangeLog | 20 +++++++++
test/Makefile.am | 18 +++++++-
test/Makefile.in | 53 ++++++++++++++++++++++-
test/Maketests | 35 +++++++++++++++
test/ar2fn_elnew_sc.awk | 9 ++++
test/ar2fn_elnew_sc.ok | 2 +
test/ar2fn_elnew_sc2.awk | 9 ++++
test/ar2fn_elnew_sc2.ok | 2 +
test/ar2fn_fmod.awk | 16 +++++++
test/{elemnew3.ok => ar2fn_fmod.ok} | 1 +
test/ar2fn_unxptyp_aref.awk | 16 +++++++
test/ar2fn_unxptyp_aref.ok | 3 ++
test/ar2fn_unxptyp_val.awk | 25 +++++++++++
test/{typeof5.ok => ar2fn_unxptyp_val.ok} | 4 +-
test/indirectbuiltin5.awk | 20 +++++++++
test/indirectbuiltin5.ok | 4 ++
test/memleak3.awk | 4 ++
test/{arrayprm2.ok => memleak3.ok} | 0
31 files changed, 503 insertions(+), 28 deletions(-)
create mode 100644 test/ar2fn_elnew_sc.awk
create mode 100644 test/ar2fn_elnew_sc.ok
create mode 100644 test/ar2fn_elnew_sc2.awk
create mode 100644 test/ar2fn_elnew_sc2.ok
create mode 100644 test/ar2fn_fmod.awk
copy test/{elemnew3.ok => ar2fn_fmod.ok} (64%)
create mode 100644 test/ar2fn_unxptyp_aref.awk
create mode 100644 test/ar2fn_unxptyp_aref.ok
create mode 100644 test/ar2fn_unxptyp_val.awk
copy test/{typeof5.ok => ar2fn_unxptyp_val.ok} (55%)
create mode 100644 test/indirectbuiltin5.awk
create mode 100644 test/indirectbuiltin5.ok
create mode 100644 test/memleak3.awk
copy test/{arrayprm2.ok => memleak3.ok} (100%)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] gawk branch, stable/pma-update, updated. gawk-4.1.0-5627-g1df8d338,
Arnold Robbins <=