From ed600e64f34ef88c1471799d7be580dee1d4b753 Mon Sep 17 00:00:00 2001 From: Serge Lamikhov-Center <to_serge@users.sourceforge.net> Date: Sun, 21 Apr 2013 16:27:43 +0300 Subject: [PATCH] Ticket #10: Fix section type SHT_NOBITS file_size calculation --- ELFIO.sln | 10 ++- elf_examples/ls.readelf | 2 +- elfio/elfio.hpp | 2 +- examples/writer/writer.vcxproj | 85 ++++++++++++++++++++++++++ examples/writer/writer.vcxproj.filters | 22 +++++++ examples/writer/writer.vcxproj.user | 7 +++ 6 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 examples/writer/writer.vcxproj create mode 100644 examples/writer/writer.vcxproj.filters create mode 100644 examples/writer/writer.vcxproj.user diff --git a/ELFIO.sln b/ELFIO.sln index e6bc855..ebad862 100644 --- a/ELFIO.sln +++ b/ELFIO.sln @@ -1,10 +1,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 11 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ELFDump", "examples\ELFDump\ELFDump.vcxproj", "{CBAA735F-E237-4976-909F-2349920ED871}" +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ELFDump", "examples\elfdump\ELFDump.vcxproj", "{CBAA735F-E237-4976-909F-2349920ED871}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ELFIOTest", "ELFIOTest\ELFIOTest.vcxproj", "{FC8A3379-B8AA-4C32-804F-F8C43AFBC2A1}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "writer", "examples\writer\writer.vcxproj", "{4E5A96DB-F6E9-4EEE-90BE-67B722DA8C84}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -19,6 +21,10 @@ Global {FC8A3379-B8AA-4C32-804F-F8C43AFBC2A1}.Debug|Win32.Build.0 = Debug|Win32 {FC8A3379-B8AA-4C32-804F-F8C43AFBC2A1}.Release|Win32.ActiveCfg = Release|Win32 {FC8A3379-B8AA-4C32-804F-F8C43AFBC2A1}.Release|Win32.Build.0 = Release|Win32 + {4E5A96DB-F6E9-4EEE-90BE-67B722DA8C84}.Debug|Win32.ActiveCfg = Debug|Win32 + {4E5A96DB-F6E9-4EEE-90BE-67B722DA8C84}.Debug|Win32.Build.0 = Debug|Win32 + {4E5A96DB-F6E9-4EEE-90BE-67B722DA8C84}.Release|Win32.ActiveCfg = Release|Win32 + {4E5A96DB-F6E9-4EEE-90BE-67B722DA8C84}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/elf_examples/ls.readelf b/elf_examples/ls.readelf index a6e1b1a..f4380d1 100644 --- a/elf_examples/ls.readelf +++ b/elf_examples/ls.readelf @@ -264,7 +264,7 @@ Relocation section '.rela.plt' at offset 0x15f8 contains 105 entries: 000000619338 006800000007 R_X86_64_JUMP_SLO 0000000000000000 __ctype_b_loc + 0 000000619340 006900000007 R_X86_64_JUMP_SLO 0000000000000000 __sprintf_chk + 0 -The decoding of unwind sections for machine type Advanced Micro Devices X86-64 is not currently supported. +There are no unwind sections in this file. Symbol table '.dynsym' contains 121 entries: Num: Value Size Type Bind Vis Ndx Name diff --git a/elfio/elfio.hpp b/elfio/elfio.hpp index 2a42a66..cb9180f 100644 --- a/elfio/elfio.hpp +++ b/elfio/elfio.hpp @@ -469,7 +469,7 @@ class elfio current_file_pos += segment_align - current_file_pos % segment_align; } - Elf_Xword current_data_pos = current_file_pos; + Elf_Xword current_data_pos = current_file_pos; Elf_Xword add_to_memory_size = 0; // Write segment's data for ( unsigned int j = 0; j <segments[i]->get_sections_num(); ++j ) { diff --git a/examples/writer/writer.vcxproj b/examples/writer/writer.vcxproj new file mode 100644 index 0000000..94a6381 --- /dev/null +++ b/examples/writer/writer.vcxproj @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{4E5A96DB-F6E9-4EEE-90BE-67B722DA8C84}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>writer</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v110</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v110</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <AdditionalIncludeDirectories>$(SolutionDir)</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="writer.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> \ No newline at end of file diff --git a/examples/writer/writer.vcxproj.filters b/examples/writer/writer.vcxproj.filters new file mode 100644 index 0000000..c3d5827 --- /dev/null +++ b/examples/writer/writer.vcxproj.filters @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="writer.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> +</Project> \ No newline at end of file diff --git a/examples/writer/writer.vcxproj.user b/examples/writer/writer.vcxproj.user new file mode 100644 index 0000000..28f7c38 --- /dev/null +++ b/examples/writer/writer.vcxproj.user @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory> + <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> + </PropertyGroup> +</Project> \ No newline at end of file -- GitLab