# non-PIC build broken on oss-fuzz

- Thread: https://externals.io/message/106909
- Original archive: https://news-web.php.net/php.internals/106909
- Started by Stanislav Malyshev on 2019-09-09T05:13:27+00:00
- Messages: 8
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #106909 — Stanislav Malyshev — 2019-09-09T05:13:27+00:00

URL: https://externals.io/message/106909#106909

Hi!

Looks like commit eef85229d0fe9f69d325aa0231e592f35c468afb broke
oss-fuzz builds:
https://oss-fuzz-build-logs.storage.googleapis.com/log-66ab74a7-4ece-4e14-b21b-f60527dd7244.txt

The error message is:

Step #4: /usr/bin/ld: dynamic STT_GNU_IFUNC symbol `php_stripslashes'
with pointer equality in `ext/standard/string.o' can not be used when
making an executable; recompile with -fPIE and relink with -pie
Step #4: clang-10: error: linker command failed with exit code 1 (use -v
to see invocation)
Step #4: make: *** [sapi/cli/php] Error 1
Step #4: Makefile:264: recipe for target 'sapi/cli/php' failed

I'm not sure I understand what's going on here - I suspect the non-PIC
build somehow conflicts with stripslashes optimizations, but I don't
know the details. May be specific to clan builds...
-- 
Stas Malyshev
smalyshev@gmail.com

---

## #106911 — Stanislav Malyshev — 2019-09-09T07:29:20+00:00

URL: https://externals.io/message/106909#106911

Hi!

> I suspect the problem caused by "-pie" linker flag (It requires all
> object files to be build with -fPIE or -fPIC).
> To quick fix this, you may add PHP configure flag "--with-pic".
> Actually, this should build PHP as before the patch.

I added --with-pic, it didn't change anything, same error.

-- 
Stas Malyshev
smalyshev@gmail.com

---

## #106912 — Christoph M. Becker — 2019-09-09T07:59:12+00:00

URL: https://externals.io/message/106909#106912 · In reply to: #106911

> > […]
>
> I added --with-pic, it didn't change anything, same error.

See <https://github.com/php/php-src/pull/4678#issuecomment-527794074>.

--
Christoph M. Becker

---

## #106913 — Stanislav Malyshev — 2019-09-09T08:03:03+00:00

URL: https://externals.io/message/106909#106913

Hi!


> how do you add "-pie" flag?

I do not. I just compile PHP. The script used to configure and build it
is here:
https://github.com/google/oss-fuzz/blob/master/projects/php/build.sh
There are no special flags there as far as I can see. The fuzzing SAPI
lives here: https://github.com/php/php-fuzzing-sapi
The compiler used is clang. You can reproduce the build by using Docker
and these instructions:
https://google.github.io/oss-fuzz/getting-started/new-project-guide/#testing-locally

Specifically:
python infra/helper.py build_image php
python infra/helper.py build_fuzzers --sanitizer address php
or, if you want to see the details, instead of second command, use:
python infra/helper.py shell php
and then:
compile

-- 
Stas Malyshev
smalyshev@gmail.com

---

## #106914 — Stanislav Malyshev — 2019-09-09T08:05:48+00:00

URL: https://externals.io/message/106909#106914 · In reply to: #106912

Hi!

> > […]
> 
> See <https://github.com/php/php-src/pull/4678#issuecomment-527794074>.

I am sorry, I don't understand how that comment helps. Could you explain
a bit further, what needs to be done to make the build work again?
configure --with-pic does not help to solve the problem.

-- 
Stas Malyshev
smalyshev@gmail.com

---

## #106919 — M. W. Moe — 2019-09-09T17:42:31+00:00

URL: https://externals.io/message/106909#106919 · In reply to: #106909

You try to mix static and dynamic linkage; there is something wrong
regarding the setup of target platform;
enumerate details about flavors.


On Sun, Sep 8, 2019 at 10:13 PM Stanislav Malyshev <smalyshev@gmail.com>
wrote:

> Hi!
>
> Looks like commit eef85229d0fe9f69d325aa0231e592f35c468afb broke
> oss-fuzz builds:
>
> https://oss-fuzz-build-logs.storage.googleapis.com/log-66ab74a7-4ece-4e14-b21b-f60527dd7244.txt
>
> The error message is:
>
> Step #4: /usr/bin/ld: dynamic STT_GNU_IFUNC symbol `php_stripslashes'
> with pointer equality in `ext/standard/string.o' can not be used when
> making an executable; recompile with -fPIE and relink with -pie
> Step #4: clang-10: error: linker command failed with exit code 1 (use -v
> to see invocation)
> Step #4: make: *** [sapi/cli/php] Error 1
> Step #4: Makefile:264: recipe for target 'sapi/cli/php' failed
>
> I'm not sure I understand what's going on here - I suspect the non-PIC
> build somehow conflicts with stripslashes optimizations, but I don't
> know the details. May be specific to clan builds...
> --
> Stas Malyshev
> smalyshev@gmail.com

---

## #106920 — M. W. Moe — 2019-09-09T17:56:23+00:00

URL: https://externals.io/message/106909#106920 · In reply to: #106919

ok got thru the link: I think it's written in plain sight `recompile with
-fPIE and relink with -pie`.



> You try to mix static and dynamic linkage; there is something wrong
> regarding the setup of target platform;
> enumerate details about flavors.
>
>
> On Sun, Sep 8, 2019 at 10:13 PM Stanislav Malyshev <smalyshev@gmail.com>
> wrote:
>
> > […]

---

## #106921 — Stanislav Malyshev — 2019-09-10T03:09:22+00:00

URL: https://externals.io/message/106909#106921

Hi!


> I've just rechecked, when PHP configured with "--with-pic", libtool
> generates only PIC object files and there is no difference between *.lo
> to *.o files.

Sorry, you were right, --with-pic works, it was my mistake.


-- 
Stas Malyshev
smalyshev@gmail.com
