What is the difference between “LSB executable” (ET_EXEC) and “LSB shared object” (ET_DYN)?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












With two files, one compiled and linked with gcc and the other manually with nasm and ld I get



  • ELF 32-bit LSB shared object ...

  • ELF 32-bit LSB executable ...

What's the difference between these two things? I can see with readelf -h that one is



  • Type: DYN (Shared object file)

  • Type: EXEC (Executable file)

I can see these documented on Wikipedia as ET_DYN and ET_EXEC. What are the practical differences between these two?










share|improve this question



























    up vote
    0
    down vote

    favorite












    With two files, one compiled and linked with gcc and the other manually with nasm and ld I get



    • ELF 32-bit LSB shared object ...

    • ELF 32-bit LSB executable ...

    What's the difference between these two things? I can see with readelf -h that one is



    • Type: DYN (Shared object file)

    • Type: EXEC (Executable file)

    I can see these documented on Wikipedia as ET_DYN and ET_EXEC. What are the practical differences between these two?










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      With two files, one compiled and linked with gcc and the other manually with nasm and ld I get



      • ELF 32-bit LSB shared object ...

      • ELF 32-bit LSB executable ...

      What's the difference between these two things? I can see with readelf -h that one is



      • Type: DYN (Shared object file)

      • Type: EXEC (Executable file)

      I can see these documented on Wikipedia as ET_DYN and ET_EXEC. What are the practical differences between these two?










      share|improve this question















      With two files, one compiled and linked with gcc and the other manually with nasm and ld I get



      • ELF 32-bit LSB shared object ...

      • ELF 32-bit LSB executable ...

      What's the difference between these two things? I can see with readelf -h that one is



      • Type: DYN (Shared object file)

      • Type: EXEC (Executable file)

      I can see these documented on Wikipedia as ET_DYN and ET_EXEC. What are the practical differences between these two?







      gcc elf ld






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 30 at 21:23









      Jeff Schaller

      33.6k851113




      33.6k851113










      asked Sep 30 at 19:05









      Evan Carroll

      4,69493775




      4,69493775




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          It seems this has something to do with Position Independent Executable (PIE). When GCC compiles executable by defaults it makes them PIE which changes the output flag on the ELF Header to ET_DYN.



          You can disable the generation of PIE executables with



          • gcc -no-pie

          If you're seeing this check the default options gcc is configured with gcc -v, you should see something like --enable-default-pie.



          Answer inspired by this submission on StackOverflow. I intend to play more with it and explain more here.






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f472449%2fwhat-is-the-difference-between-lsb-executable-et-exec-and-lsb-shared-object%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            It seems this has something to do with Position Independent Executable (PIE). When GCC compiles executable by defaults it makes them PIE which changes the output flag on the ELF Header to ET_DYN.



            You can disable the generation of PIE executables with



            • gcc -no-pie

            If you're seeing this check the default options gcc is configured with gcc -v, you should see something like --enable-default-pie.



            Answer inspired by this submission on StackOverflow. I intend to play more with it and explain more here.






            share|improve this answer
























              up vote
              0
              down vote













              It seems this has something to do with Position Independent Executable (PIE). When GCC compiles executable by defaults it makes them PIE which changes the output flag on the ELF Header to ET_DYN.



              You can disable the generation of PIE executables with



              • gcc -no-pie

              If you're seeing this check the default options gcc is configured with gcc -v, you should see something like --enable-default-pie.



              Answer inspired by this submission on StackOverflow. I intend to play more with it and explain more here.






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                It seems this has something to do with Position Independent Executable (PIE). When GCC compiles executable by defaults it makes them PIE which changes the output flag on the ELF Header to ET_DYN.



                You can disable the generation of PIE executables with



                • gcc -no-pie

                If you're seeing this check the default options gcc is configured with gcc -v, you should see something like --enable-default-pie.



                Answer inspired by this submission on StackOverflow. I intend to play more with it and explain more here.






                share|improve this answer












                It seems this has something to do with Position Independent Executable (PIE). When GCC compiles executable by defaults it makes them PIE which changes the output flag on the ELF Header to ET_DYN.



                You can disable the generation of PIE executables with



                • gcc -no-pie

                If you're seeing this check the default options gcc is configured with gcc -v, you should see something like --enable-default-pie.



                Answer inspired by this submission on StackOverflow. I intend to play more with it and explain more here.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 30 at 19:14









                Evan Carroll

                4,69493775




                4,69493775



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f472449%2fwhat-is-the-difference-between-lsb-executable-et-exec-and-lsb-shared-object%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Peggy Mitchell

                    Palaiologos

                    The Forum (Inglewood, California)