aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/utils/make_preload
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-02-17 12:03:08 +0100
committerBjörn Gustavsson <[email protected]>2017-02-17 12:35:49 +0100
commit5263d10ba361cf0666cb6b2730132a018ba67bd6 (patch)
tree57023886ebc46af04caac6137d2eb97976926955 /erts/emulator/utils/make_preload
parent5b80964cabcb5ec6c7961d3714fa9ed4bdcc6585 (diff)
downloadotp-5263d10ba361cf0666cb6b2730132a018ba67bd6.tar.gz
otp-5263d10ba361cf0666cb6b2730132a018ba67bd6.tar.bz2
otp-5263d10ba361cf0666cb6b2730132a018ba67bd6.zip
Teach make_preload to handle the new 'AtU8' chunk
26b59dfe67 introduced the new 'AtU8' chunk to support Unicode atoms. make_preload strips the pre-loaded BEAM files so that they only contain essential chunks. It expects to find the old 'Atom' chunk. Teach make_preload to read the new 'AtU8' chunk instead of the old chunk. Also produce a nice error message if someone by mistake compiles the pre-loaded modules with an OTP 19 compiler.
Diffstat (limited to 'erts/emulator/utils/make_preload')
-rwxr-xr-xerts/emulator/utils/make_preload18
1 files changed, 13 insertions, 5 deletions
diff --git a/erts/emulator/utils/make_preload b/erts/emulator/utils/make_preload
index 8b629d9517..bcb2e42614 100755
--- a/erts/emulator/utils/make_preload
+++ b/erts/emulator/utils/make_preload
@@ -90,7 +90,7 @@ foreach $file (@ARGV) {
open(FILE, $file) or error("failed to read $file: $!");
binmode(FILE);
$_ = <FILE>;
- $_ = beam_strip($_);
+ $_ = beam_strip($_, $file);
close(FILE);
push(@modules, " {\"$module\", " . length($_) . ", preloaded_$module},\n");
@@ -147,20 +147,20 @@ sub error {
}
sub beam_strip {
- my($beam) = @_;
+ my($beam,$file) = @_;
my $size_left = length($beam);
my %chunk;
my %needed_chunk = ('Code' => 1,
- 'Atom' => 1,
+ 'AtU8' => 1,
'ImpT' => 1,
'ExpT' => 1,
'StrT' => 1,
'FunT' => 1,
'LitT' => 1);
- die "can't read Beam files for OTP R4 or earlier (sorry)"
+ die "$file: can't read Beam files for OTP R4 or earlier (sorry)"
if $beam =~ /^\x7fBEAM!/;
#
@@ -177,7 +177,7 @@ sub beam_strip {
die "form size $size greater than size ", $size_left, " of module"
if $size > $size_left;
$size_left -= 4;
- die "not a BEAM file: IFF form type is not 'BEAM'"
+ die "$file: not a BEAM file: IFF form type is not 'BEAM'"
unless $beam_id eq 'BEAM';
#
@@ -197,6 +197,14 @@ sub beam_strip {
}
#
+ # Abort if there is no new-style 'AtU8' atom chunk.
+ #
+
+ exists $chunk{'AtU8'} or
+ die "$file: no 'AtU8' chunk (re-compile with " .
+ "OTP 20 or later)\n";
+
+ #
# Create a new beam file with only the useful chunk types.
#