From f46384a8f24e0994481f58eb8a2dd326a921c7bf Mon Sep 17 00:00:00 2001 From: eshiner Date: Fri, 12 Dec 2025 10:22:55 +0800 Subject: [PATCH] fix apply patch error by remove 0118-upatch-build-support-text-section-offset.patch Signed-off-by: eshiner (cherry picked from commit b283ba1426700cfcad9fe52f8ac38e64aa56fb15) --- ...ch-build-support-text-section-offset.patch | 101 ------------------ syscare.spec | 7 +- 2 files changed, 5 insertions(+), 103 deletions(-) delete mode 100644 0118-upatch-build-support-text-section-offset.patch diff --git a/0118-upatch-build-support-text-section-offset.patch b/0118-upatch-build-support-text-section-offset.patch deleted file mode 100644 index 1350de9..0000000 --- a/0118-upatch-build-support-text-section-offset.patch +++ /dev/null @@ -1,101 +0,0 @@ -From ea5db116bc4e72ad8ff91afc88d6f7b9abcd5d92 Mon Sep 17 00:00:00 2001 -From: renoseven -Date: Mon, 12 May 2025 11:23:52 +0800 -Subject: [PATCH] upatch-build: support text section offset - -Signed-off-by: renoseven ---- - upatch-build/src/main.rs | 49 ++++++++++++++++++++++++++++++++-------- - 1 file changed, 39 insertions(+), 10 deletions(-) - -diff --git a/upatch-build/src/main.rs b/upatch-build/src/main.rs -index 6b48b78..29d68f6 100644 ---- a/upatch-build/src/main.rs -+++ b/upatch-build/src/main.rs -@@ -194,6 +194,23 @@ impl UpatchBuild { - .exit_ok() - } - -+ fn parse_text_offset(&self, binary: &Path) -> Result { -+ const TEXT_SECTION_NAME: &str = ".text"; -+ -+ let mmap = fs::mmap(binary)?; -+ let file = object::File::parse(mmap.as_ref())?; -+ let text_offset = file -+ .section_by_name(TEXT_SECTION_NAME) -+ .map(|section| { -+ let address = section.address(); -+ let offset = section.file_range().map(|(start, _)| start).unwrap_or(0); -+ address - offset -+ }) -+ .unwrap_or(0); -+ -+ Ok(text_offset) -+ } -+ - fn build_patch(&self, patch_name: &OsStr, binary: &Path, debuginfo: &Path) -> Result<()> { - const NOTES_OBJECT_NAME: &str = "notes.o"; - -@@ -222,6 +239,9 @@ impl UpatchBuild { - .binary_objects(binary) - .with_context(|| format!("Failed to find objects of {}", binary.display()))?; - -+ let text_offset = self -+ .parse_text_offset(binary) -+ .with_context(|| format!("Failed to parse {} text section offset", binary.display()))?; - for (patched_object, original_object) in binary_objects { - debug!( - "* {}", -@@ -230,13 +250,19 @@ impl UpatchBuild { - .unwrap_or(patched_object.as_os_str()) - .to_string_lossy() - ); -- Self::create_diff_objs(original_object, patched_object, &debuginfo_file, &temp_dir) -- .with_context(|| { -- format!( -- "Failed to create diff objects for {}", -- patch_name.to_string_lossy() -- ) -- })?; -+ Self::create_diff_objs( -+ original_object, -+ patched_object, -+ &debuginfo_file, -+ text_offset, -+ &temp_dir, -+ ) -+ .with_context(|| { -+ format!( -+ "Failed to create diff objects for {}", -+ patch_name.to_string_lossy() -+ ) -+ })?; - } - - debug!("- Collecting changes"); -@@ -436,6 +462,7 @@ impl UpatchBuild { - original_object: &Path, - patched_object: &Path, - debuginfo: &Path, -+ text_offset: u64, - output_dir: &Path, - ) -> Result<()> { - let ouput_name = original_object.file_name().with_context(|| { -@@ -453,9 +480,11 @@ impl UpatchBuild { - .arg("-p") - .arg(patched_object) - .arg("-r") -- .arg(debuginfo) -- .arg("-o") -- .arg(output_file); -+ .arg(debuginfo); -+ if text_offset > 0 { -+ command.arg("-t").arg(text_offset.to_string()); -+ } -+ command.arg("-o").arg(output_file); - - command.stdout(Level::Trace).run_with_output()?.exit_ok() - } --- -2.43.0 - diff --git a/syscare.spec b/syscare.spec index 0cb73e4..e7d095d 100644 --- a/syscare.spec +++ b/syscare.spec @@ -5,7 +5,7 @@ ############################################ Name: syscare Version: 1.2.2 -Release: 7 +Release: 8 Summary: System hot-fix service License: MulanPSL-2.0 and GPL-2.0-only URL: https://gitee.com/openeuler/syscare @@ -137,7 +137,7 @@ Patch0114: 0114-upatch-build-fix-unable-to-find-object-linker-error.patch Patch0115: 0115-upatch-build-warning-on-finding-patched-object-failu.patch Patch0116: 0116-upatch-build-try-hardlink-before-copy-files.patch Patch0117: 0117-upatch-build-optimize-code.patch -Patch0118: 0118-upatch-build-support-text-section-offset.patch +# Patch0118: 0118-upatch-build-support-text-section-offset.patch Patch0119: 0119-syscare-build-fix-clippy-warnings.patch Patch0120: 0120-project-update-Cargo.lock.patch Patch0121: 0121-project-change-compile-options.patch @@ -288,6 +288,9 @@ Syscare patch building toolset. ################ Change log ################ ############################################ %changelog +* Fri Dec 12 2025 eshiner - 1.2.2-8 +- bugfix: fix apply patch error + * Sat Aug 30 2025 renoseven - 1.2.2-7 - change: add debuginfo package version verification in syscare-build - change: rename "--keep-line-macros" to "--override-line-macros" in syscare-build -- Gitee