[FFmpeg-trac] #9612(undetermined:closed): --enable-pic flag doesn't affect the object files from assembly

FFmpeg trac at avcodec.org
Mon Oct 17 06:01:52 EEST 2022


#9612: --enable-pic flag doesn't affect the object files from assembly
-------------------------------------+-------------------------------------
             Reporter:  Tuğrul       |                    Owner:  (none)
                 Type:  defect       |                   Status:  closed
             Priority:  normal       |                Component:
                                     |  undetermined
              Version:  unspecified  |               Resolution:
                                     |  needs_more_info
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
Comment (by mkver):

 When the compiler builds code, it presumes that every symbol that is not
 local (static) to one file has default elf visibility and therefore might
 come from a different library at runtime (due to interposing); yet our
 assembly never uses objects from different libraries and always creates
 functions in such a way that they expect these objects to be in the same
 library. Some of these objects used by assembly are created by non-
 assembly and therefore have default visibility (because we don't use
 -fvisibility at all). Instead we typically use -Bsymbolic and also a
 linker version script telling to mark the symbols that are intended to be
 exported. This informs the linker that objects like ff_pw_5 will always
 come from the same library, so that a R_X86_64_PC32 relocation is
 permissible.

 So you should use a linker script like

 {{{
 {
     global:
         av*;
         postproc_*;
         pp_*;
         swr_*;
         swresample_*;
         swscale_*;
         sws_*;
     local:
         *;
 };
 }}}

 by adding "-Wl,--version-script=<name of the file containing the above>"
 to your command line. You can also add "-Wl,--Bsymbolic" to bind functions
 from your library local if possible (i.e. ignore interposing for them;
 actually either of these options is sufficient to make the link succeed,
 but using a version script has the advantage of not exporting stuff that
 is not meant to be exported, whereas Bsymbolic speeds up calls to
 functions that are exported, but are also called from within the newly
 created library). You will also have to add "-Wl,--allow-multiple-
 definition" due to the half2float stuff being duplicated into multiple
 libraries (the linker ordinarily only uses the one from the first library,
 but your --whole-archive overrides it).
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9612#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list