-
when using github,
./configure
is not present and didn't know how to start -
download from http://php.net/downloads.php
-
downloading specific version http://php.net/get/php-5.6.30.tar.gz/from/a/mirror
-
I want to build minimal version only for testing
-
following http://www.phpinternalsbook.com/build_system/building_php.html#obtaining-the-source-code
-
Run
./configure --disable-all
-
Run
time make
-
OR run both at the same time
time ./configure --disable-all && time make
-
check version at
sapi/cli/php -v
-
Run
sapi/cli/php -m
should give minimal number of modules only[PHP Modules] Core date ereg pcre Reflection SPL standard
-
random looking for main function, just looking at file names
-
found
php_execute_script
inphp_main.h
-
found definition in
main.c
-
Added
printf("Running php_execute_script");
in that function And i can see that incli
-
Run
/Users/anjesh/Dev/source/php-5.6.30/sapi/cli/php test.php
-
It appears that i don't have to run
./configure
everytime after making changes in the source. This makes the build quick. -
http://jpauli.github.io/2015/01/22/on-php-function-calls.html
-
https://www.slideshare.net/jpauli/quick-tour-of-php-from-inside
- got info from https://ctors.net/2015/09/11/php_opcodes
- clone https://github.com/derickr/vld
- compiled and copy to local folder when test.php is present
- Run
php -dextension=./vld.so -dvld.active=1 test.php
and got the op_codes or - Run
/Users/anjesh/Dev/source/php-5.6.30/sapi/cli/php -dextension=./vld.so -dvld.active=1 test.php
and got the op_codes
- http://php.find-info.ru/php/016/ch20lev1sec3.html
- https://stackoverflow.com/questions/8340991/how-does-php-opcode-relate-to-the-actually-executed-binary-code
- http://jpauli.github.io/2015/01/22/on-php-function-calls.html has details on func calls
-
searched for
Call to undefined function
from http://jpauli.github.io/2015/01/22/on-php-function-calls.html -
found
zend_vm_execute.c
file -
just scanning the file and found
execute_ex
which appears to be loop -
put some printf command there
-
Run
/Users/anjesh/Dev/source/php-5.6.30/sapi/cli/php test.php
and got that printf msg -
Read README.ZEND_VM file and it talks about
zend_vm_def.h
, which is mentioned inzend_vm_gen.php
and that file has some comments that it generates filesThis script creates zend_vm_execute.h and zend_vm_opcodes.h from existing zend_vm_def.h and zend_vm_execute.skl
-
Run
/Users/anjesh/Dev/source/php-5.6.30/sapi/cli/php Zend/zend_vm_gen.php
and comment inzend_vm_def.h
is reflected inzend_vm_execute.c
-
http://jpauli.github.io/2015/01/22/on-php-function-calls.html content is present in
zend_vm_def.h
-
php under the hoods https://www.youtube.com/watch?v=tyEFF7brU-I
-
message is coming from
zend_verify_arg_class_kind
inzend_execute.c
, when searched forinstance of
text of the error message. -
found where the message is coming from in
zend_execute.c
else if (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value TSRMLS_CC)))) {
need_msg = zend_verify_arg_class_kind(cur_arg_info, fetch_type, &class_name, &ce TSRMLS_CC);
return zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, need_msg, class_name, zend_zval_type_name(arg), "" TSRMLS_CC);
}
- i can replace
need_msg = zend_verify_arg_class_kind(cur_arg_info, fetch_type, &class_name, &ce TSRMLS_CC);
withclass_name = " myclass "; need_msg = " hello ";
and the output message is changed. - if i comment above line, the output appears, infact it doesn't check for the typehint in the function param