|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-02-10 05:48 UTC] chibisuke at web dot de
Description:
------------
a bcompiled php script that has been compiled to into an executable on FreeBSD 9 (amd64) cannot be loaded by bcompiler_load_exe.
After diging a bit into the code
Test script:
---------------
Creating the output file:
<?php
function main() {
echo "hello world";
}
$fh = fopen("output", "wb");
$size = filesize("phpe");
$fr = fopen("phpe", "rb");
fwrite($fh, fread($fr, $size), $size);
$startpos = ftell($fh);
$fh = fopen("output", "w");
bcompiler_write_header($fh);
bcompiler_write_class($fh, "test");
bcompiler_write_function($fh, "main");
bcompiler_write_footer($fh);
bcompiler_write_exe_footer($fh, $startpos);
?>
Loading the file:
<?php
bcompiler_load_exe('output');
print_r(get_declared_classes());
?>
Expected result:
----------------
> Hello World
Actual result:
--------------
PHP Fatal error: Could not find Magic header in stream in /root/ad/test.php on line 2
Fatal error: Could not find Magic header in stream in /root/ad/test.php on line 2
Patcheschange-4byte-to-dynamic (last revision 2012-02-10 06:04 UTC by chibisuke at web dot de)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 09:00:02 2025 UTC |
Oups... in the create script I forgot a debug line. here's the correct one: Creating the output file: <?php function main() { echo "hello world"; } $fh = fopen("output", "wb"); $size = filesize("phpe"); $fr = fopen("phpe", "rb"); fwrite($fh, fread($fr, $size), $size); $startpos = ftell($fh); bcompiler_write_header($fh); bcompiler_write_class($fh, "test"); bcompiler_write_function($fh, "main"); bcompiler_write_footer($fh); bcompiler_write_exe_footer($fh, $startpos); ?>