From f0bd9763ea4be22f0f235c0f3aa6628944a56c7e Mon Sep 17 00:00:00 2001 From: Franciszek Malinka Date: Thu, 6 May 2021 14:28:59 +0200 Subject: Aktualizacja --- Semestr 4/ask/lista7/zad7.ll | 174 +++++++++++ Semestr 4/ask/lista8/._lista_8 | Bin 0 -> 212 bytes Semestr 4/ask/lista8/ask21_lista_8.tgz | Bin 0 -> 2136 bytes Semestr 4/ask/lista8/bar.c | 5 + Semestr 4/ask/lista8/even.c | 8 + Semestr 4/ask/lista8/foo.c | 5 + Semestr 4/ask/lista8/lazy.c | 7 + Semestr 4/ask/lista8/main.lds | 39 +++ Semestr 4/ask/lista8/merge-1.map | 300 +++++++++++++++++++ Semestr 4/ask/lista8/merge-2.map | 301 +++++++++++++++++++ Semestr 4/ask/lista8/mismatch-a.c | 7 + Semestr 4/ask/lista8/mismatch-b.c | 8 + Semestr 4/ask/lista8/odd.c | 8 + Semestr 4/ask/lista8/relo3.c | 15 + Semestr 4/ask/lista8/start.c | 8 + Semestr 4/ask/lista8/str-a.c | 10 + Semestr 4/ask/lista8/str-b.c | 9 + Semestr 4/ask/lista8/swap.c | 18 ++ Semestr 4/ask/lista9/gadget.s | 16 ++ Semestr 4/ask/lista9/lazy.c | 7 + Semestr 4/ask/lista9/lista_9.tgz | Bin 0 -> 1278 bytes Semestr 4/ask/lista9/relo3.c | 15 + Semestr 4/ask/lista9/ropex.c | 31 ++ Semestr 4/ask/lista9/ropex.in (1).txt | 7 + Semestr 4/ask/lista9/ropex.in.txt | 7 + Semestr 4/ask/lista9/ropex.map | 511 +++++++++++++++++++++++++++++++++ Semestr 4/ask/lista9/test.c | 7 + Semestr 4/ask/lista9/test.s | 50 ++++ 28 files changed, 1573 insertions(+) create mode 100644 Semestr 4/ask/lista7/zad7.ll create mode 100755 Semestr 4/ask/lista8/._lista_8 create mode 100644 Semestr 4/ask/lista8/ask21_lista_8.tgz create mode 100644 Semestr 4/ask/lista8/bar.c create mode 100644 Semestr 4/ask/lista8/even.c create mode 100644 Semestr 4/ask/lista8/foo.c create mode 100644 Semestr 4/ask/lista8/lazy.c create mode 100644 Semestr 4/ask/lista8/main.lds create mode 100644 Semestr 4/ask/lista8/merge-1.map create mode 100644 Semestr 4/ask/lista8/merge-2.map create mode 100644 Semestr 4/ask/lista8/mismatch-a.c create mode 100644 Semestr 4/ask/lista8/mismatch-b.c create mode 100644 Semestr 4/ask/lista8/odd.c create mode 100644 Semestr 4/ask/lista8/relo3.c create mode 100644 Semestr 4/ask/lista8/start.c create mode 100644 Semestr 4/ask/lista8/str-a.c create mode 100644 Semestr 4/ask/lista8/str-b.c create mode 100644 Semestr 4/ask/lista8/swap.c create mode 100644 Semestr 4/ask/lista9/gadget.s create mode 100644 Semestr 4/ask/lista9/lazy.c create mode 100644 Semestr 4/ask/lista9/lista_9.tgz create mode 100644 Semestr 4/ask/lista9/relo3.c create mode 100644 Semestr 4/ask/lista9/ropex.c create mode 100644 Semestr 4/ask/lista9/ropex.in (1).txt create mode 100644 Semestr 4/ask/lista9/ropex.in.txt create mode 100644 Semestr 4/ask/lista9/ropex.map create mode 100644 Semestr 4/ask/lista9/test.c create mode 100644 Semestr 4/ask/lista9/test.s (limited to 'Semestr 4/ask') diff --git a/Semestr 4/ask/lista7/zad7.ll b/Semestr 4/ask/lista7/zad7.ll new file mode 100644 index 0000000..a99e8d8 --- /dev/null +++ b/Semestr 4/ask/lista7/zad7.ll @@ -0,0 +1,174 @@ +; ModuleID = 'zad7.cpp' +source_filename = "zad7.cpp" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +%struct.Base = type <{ i32 (...)**, i32, [4 x i8] }> +%struct.Derived = type { %struct.Base.base, [4 x i8] } +%struct.Base.base = type <{ i32 (...)**, i32 }> + +$_ZN4BaseC1Ei = comdat any + +$_ZN7DerivedC1Ei = comdat any + +$_ZN4BaseC2Ei = comdat any + +$_ZN4Base4doitEi = comdat any + +$_ZN7DerivedC2Ei = comdat any + +$_ZN7Derived4doitEi = comdat any + +$_ZTV4Base = comdat any + +$_ZTS4Base = comdat any + +$_ZTI4Base = comdat any + +$_ZTV7Derived = comdat any + +$_ZTS7Derived = comdat any + +$_ZTI7Derived = comdat any + +@_ZTV4Base = linkonce_odr unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI4Base to i8*), i8* bitcast (i32 (%struct.Base*, i32)* @_ZN4Base4doitEi to i8*)] }, comdat, align 8 +@_ZTVN10__cxxabiv117__class_type_infoE = external global i8* +@_ZTS4Base = linkonce_odr constant [6 x i8] c"4Base\00", comdat, align 1 +@_ZTI4Base = linkonce_odr constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @_ZTS4Base, i32 0, i32 0) }, comdat, align 8 +@_ZTV7Derived = linkonce_odr unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTI7Derived to i8*), i8* bitcast (i32 (%struct.Derived*, i32)* @_ZN7Derived4doitEi to i8*)] }, comdat, align 8 +@_ZTVN10__cxxabiv120__si_class_type_infoE = external global i8* +@_ZTS7Derived = linkonce_odr constant [9 x i8] c"7Derived\00", comdat, align 1 +@_ZTI7Derived = linkonce_odr constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @_ZTS7Derived, i32 0, i32 0), i8* bitcast ({ i8*, i8* }* @_ZTI4Base to i8*) }, comdat, align 8 + +; Function Attrs: noinline nounwind optnone +define i32 @_Z4doitP4Base(%struct.Base* %bp) #0 { +entry: + %bp.addr = alloca %struct.Base*, align 8 + store %struct.Base* %bp, %struct.Base** %bp.addr, align 8 + %0 = load %struct.Base*, %struct.Base** %bp.addr, align 8 + %1 = bitcast %struct.Base* %0 to i32 (%struct.Base*, i32)*** + %vtable = load i32 (%struct.Base*, i32)**, i32 (%struct.Base*, i32)*** %1, align 8 + %vfn = getelementptr inbounds i32 (%struct.Base*, i32)*, i32 (%struct.Base*, i32)** %vtable, i64 0 + %2 = load i32 (%struct.Base*, i32)*, i32 (%struct.Base*, i32)** %vfn, align 8 + %call = call i32 %2(%struct.Base* %0, i32 1) + ret i32 %call +} + +; Function Attrs: noinline norecurse nounwind optnone +define i32 @main(i32 %argc, i8** %argv) #1 { +entry: + %retval = alloca i32, align 4 + %argc.addr = alloca i32, align 4 + %argv.addr = alloca i8**, align 8 + %b = alloca %struct.Base, align 8 + %d = alloca %struct.Derived, align 8 + store i32 0, i32* %retval, align 4 + store i32 %argc, i32* %argc.addr, align 4 + store i8** %argv, i8*** %argv.addr, align 8 + call void @_ZN4BaseC1Ei(%struct.Base* %b, i32 10) + call void @_ZN7DerivedC1Ei(%struct.Derived* %d, i32 20) + %call = call i32 @_Z4doitP4Base(%struct.Base* %b) + %0 = bitcast %struct.Derived* %d to %struct.Base* + %call1 = call i32 @_Z4doitP4Base(%struct.Base* %0) + %add = add nsw i32 %call, %call1 + ret i32 %add +} + +; Function Attrs: noinline nounwind optnone +define linkonce_odr void @_ZN4BaseC1Ei(%struct.Base* %this, i32 %n) unnamed_addr #0 comdat align 2 { +entry: + %this.addr = alloca %struct.Base*, align 8 + %n.addr = alloca i32, align 4 + store %struct.Base* %this, %struct.Base** %this.addr, align 8 + store i32 %n, i32* %n.addr, align 4 + %this1 = load %struct.Base*, %struct.Base** %this.addr, align 8 + %0 = load i32, i32* %n.addr, align 4 + call void @_ZN4BaseC2Ei(%struct.Base* %this1, i32 %0) + ret void +} + +; Function Attrs: noinline nounwind optnone +define linkonce_odr void @_ZN7DerivedC1Ei(%struct.Derived* %this, i32 %n) unnamed_addr #0 comdat align 2 { +entry: + %this.addr = alloca %struct.Derived*, align 8 + %n.addr = alloca i32, align 4 + store %struct.Derived* %this, %struct.Derived** %this.addr, align 8 + store i32 %n, i32* %n.addr, align 4 + %this1 = load %struct.Derived*, %struct.Derived** %this.addr, align 8 + %0 = load i32, i32* %n.addr, align 4 + call void @_ZN7DerivedC2Ei(%struct.Derived* %this1, i32 %0) + ret void +} + +; Function Attrs: noinline nounwind optnone +define linkonce_odr void @_ZN4BaseC2Ei(%struct.Base* %this, i32 %n) unnamed_addr #0 comdat align 2 { +entry: + %this.addr = alloca %struct.Base*, align 8 + %n.addr = alloca i32, align 4 + store %struct.Base* %this, %struct.Base** %this.addr, align 8 + store i32 %n, i32* %n.addr, align 4 + %this1 = load %struct.Base*, %struct.Base** %this.addr, align 8 + %0 = bitcast %struct.Base* %this1 to i32 (...)*** + store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV4Base, i32 0, inrange i32 0, i32 2) to i32 (...)**), i32 (...)*** %0, align 8 + %data = getelementptr inbounds %struct.Base, %struct.Base* %this1, i32 0, i32 1 + %1 = load i32, i32* %n.addr, align 4 + store i32 %1, i32* %data, align 8 + ret void +} + +; Function Attrs: noinline nounwind optnone +define linkonce_odr i32 @_ZN4Base4doitEi(%struct.Base* %this, i32 %n) unnamed_addr #0 comdat align 2 { +entry: + %this.addr = alloca %struct.Base*, align 8 + %n.addr = alloca i32, align 4 + store %struct.Base* %this, %struct.Base** %this.addr, align 8 + store i32 %n, i32* %n.addr, align 4 + %this1 = load %struct.Base*, %struct.Base** %this.addr, align 8 + %0 = load i32, i32* %n.addr, align 4 + %data = getelementptr inbounds %struct.Base, %struct.Base* %this1, i32 0, i32 1 + %1 = load i32, i32* %data, align 8 + %sub = sub nsw i32 %0, %1 + ret i32 %sub +} + +; Function Attrs: noinline nounwind optnone +define linkonce_odr void @_ZN7DerivedC2Ei(%struct.Derived* %this, i32 %n) unnamed_addr #0 comdat align 2 { +entry: + %this.addr = alloca %struct.Derived*, align 8 + %n.addr = alloca i32, align 4 + store %struct.Derived* %this, %struct.Derived** %this.addr, align 8 + store i32 %n, i32* %n.addr, align 4 + %this1 = load %struct.Derived*, %struct.Derived** %this.addr, align 8 + %0 = bitcast %struct.Derived* %this1 to %struct.Base* + %1 = load i32, i32* %n.addr, align 4 + %add = add nsw i32 %1, 1 + call void @_ZN4BaseC2Ei(%struct.Base* %0, i32 %add) + %2 = bitcast %struct.Derived* %this1 to i32 (...)*** + store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV7Derived, i32 0, inrange i32 0, i32 2) to i32 (...)**), i32 (...)*** %2, align 8 + ret void +} + +; Function Attrs: noinline nounwind optnone +define linkonce_odr i32 @_ZN7Derived4doitEi(%struct.Derived* %this, i32 %n) unnamed_addr #0 comdat align 2 { +entry: + %this.addr = alloca %struct.Derived*, align 8 + %n.addr = alloca i32, align 4 + store %struct.Derived* %this, %struct.Derived** %this.addr, align 8 + store i32 %n, i32* %n.addr, align 4 + %this1 = load %struct.Derived*, %struct.Derived** %this.addr, align 8 + %0 = load i32, i32* %n.addr, align 4 + %1 = bitcast %struct.Derived* %this1 to %struct.Base* + %data = getelementptr inbounds %struct.Base, %struct.Base* %1, i32 0, i32 1 + %2 = load i32, i32* %data, align 8 + %mul = mul nsw i32 %0, %2 + ret i32 %mul +} + +attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { noinline norecurse nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.module.flags = !{!0} +!llvm.ident = !{!1} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{!"clang version 10.0.0-4ubuntu1 "} diff --git a/Semestr 4/ask/lista8/._lista_8 b/Semestr 4/ask/lista8/._lista_8 new file mode 100755 index 0000000..893436c Binary files /dev/null and b/Semestr 4/ask/lista8/._lista_8 differ diff --git a/Semestr 4/ask/lista8/ask21_lista_8.tgz b/Semestr 4/ask/lista8/ask21_lista_8.tgz new file mode 100644 index 0000000..789c9af Binary files /dev/null and b/Semestr 4/ask/lista8/ask21_lista_8.tgz differ diff --git a/Semestr 4/ask/lista8/bar.c b/Semestr 4/ask/lista8/bar.c new file mode 100644 index 0000000..97fbd4f --- /dev/null +++ b/Semestr 4/ask/lista8/bar.c @@ -0,0 +1,5 @@ +// extern long foo; + +int bar = 42; +// long *foo_p = &foo; +short dead[15]; diff --git a/Semestr 4/ask/lista8/even.c b/Semestr 4/ask/lista8/even.c new file mode 100644 index 0000000..5bf8606 --- /dev/null +++ b/Semestr 4/ask/lista8/even.c @@ -0,0 +1,8 @@ +int is_odd(long n); + +int is_even(long n) { + if (n == 0) + return 1; + else + return is_odd(n - 1); +} diff --git a/Semestr 4/ask/lista8/foo.c b/Semestr 4/ask/lista8/foo.c new file mode 100644 index 0000000..080d831 --- /dev/null +++ b/Semestr 4/ask/lista8/foo.c @@ -0,0 +1,5 @@ +// extern int bar; + +long foo = 19; +// int *bar_p = &bar; +char code[17]; diff --git a/Semestr 4/ask/lista8/lazy.c b/Semestr 4/ask/lista8/lazy.c new file mode 100644 index 0000000..fb08cf7 --- /dev/null +++ b/Semestr 4/ask/lista8/lazy.c @@ -0,0 +1,7 @@ +#include + +int main(void) { + puts("first time"); + puts("second time"); + return 0; +} diff --git a/Semestr 4/ask/lista8/main.lds b/Semestr 4/ask/lista8/main.lds new file mode 100644 index 0000000..25a4ca9 --- /dev/null +++ b/Semestr 4/ask/lista8/main.lds @@ -0,0 +1,39 @@ +OUTPUT_FORMAT("elf64-x86-64") +OUTPUT_ARCH(i386:x86-64) +ENTRY(_start) +PHDRS +{ + code PT_LOAD FLAGS(5); + rodata PT_LOAD FLAGS(4); + data PT_LOAD FLAGS(6); +} +SECTIONS +{ + . = 0x400000 + SIZEOF_HEADERS; + + .text : + { + *(.text .text.*) + } : code + + .rodata : + { + *(.rodata .rodata.*) + } : rodata + + .data : + { + *(.data .data.*) + } : data + + .bss : + { + *(.bss .bss.*) + *(COMMON) + } : data + + /DISCARD/ : + { + *(.note.gnu.property) + } +} diff --git a/Semestr 4/ask/lista8/merge-1.map b/Semestr 4/ask/lista8/merge-1.map new file mode 100644 index 0000000..2e93e7c --- /dev/null +++ b/Semestr 4/ask/lista8/merge-1.map @@ -0,0 +1,300 @@ + +Merging program properties + + +Discarded input sections + + .note.gnu.property + 0x0000000000000000 0x20 bar.o + +Memory Configuration + +Name Origin Length Attributes +*default* 0x0000000000000000 0xffffffffffffffff + +Linker script and memory map + +LOAD foo.o +LOAD bar.o + +.interp + *(.interp) + +.note.gnu.property + 0x0000000000000000 0x20 + .note.gnu.property + 0x0000000000000000 0x20 foo.o + +.note.gnu.build-id + *(.note.gnu.build-id) + +.hash + *(.hash) + +.gnu.hash + *(.gnu.hash) + +.dynsym + *(.dynsym) + +.dynstr + *(.dynstr) + +.gnu.version + *(.gnu.version) + +.gnu.version_d + *(.gnu.version_d) + +.gnu.version_r + *(.gnu.version_r) + +.rela.init + *(.rela.init) + +.rela.text + *(.rela.text) + +.rela.fini + *(.rela.fini) + +.rela.rodata + *(.rela.rodata) + +.rela.data.rel.ro + *(.rela.data.rel.ro) + +.rela.data + *(.rela.data) + +.rela.tdata + *(.rela.tdata) + +.rela.tbss + *(.rela.tbss) + +.rela.ctors + *(.rela.ctors) + +.rela.dtors + *(.rela.dtors) + +.rela.got + *(.rela.got) + +.rela.bss + *(.rela.bss) + +.rela.ldata + *(.rela.ldata) + +.rela.lbss + *(.rela.lbss) + +.rela.lrodata + *(.rela.lrodata) + +.rela.ifunc + *(.rela.ifunc) + +.rela.plt + *(.rela.plt) + +.init + *(SORT_NONE(.init)) + +.plt + *(.plt) + +.plt.got + *(.plt.got) + +.plt.sec + *(.plt.sec) + +.text 0x0000000000000000 0x0 + *(.text .stub) + .text 0x0000000000000000 0x0 foo.o + .text 0x0000000000000000 0x0 bar.o + *(.gnu.warning) + +.fini + *(SORT_NONE(.fini)) + +.rodata + *(.rodata) + +.rodata1 + *(.rodata1) + +.eh_frame_hdr + *(.eh_frame_hdr) + +.eh_frame + *(.eh_frame) + +.gcc_except_table + *(.gcc_except_table) + +.gnu_extab + *(.gnu_extab*) + +.exception_ranges + *(.exception_ranges) + +.eh_frame + *(.eh_frame) + +.gnu_extab + *(.gnu_extab) + +.gcc_except_table + *(.gcc_except_table) + +.exception_ranges + *(.exception_ranges) + +.tdata + *(.tdata) + +.tbss + *(.tbss) + +.jcr + *(.jcr) + +.dynamic + *(.dynamic) + +.got + *(.got) + +.got.plt + *(.got.plt) + +.data 0x0000000000000000 0xc + *(.data) + .data 0x0000000000000000 0x8 foo.o + 0x0000000000000000 foo + .data 0x0000000000000008 0x4 bar.o + 0x0000000000000008 bar + +.data1 + *(.data1) + +.bss 0x0000000000000000 0x3e + *(.bss) + .bss 0x0000000000000000 0x11 foo.o + 0x0000000000000000 code + *fill* 0x0000000000000011 0xf + .bss 0x0000000000000020 0x1e bar.o + 0x0000000000000020 dead + +.lbss + *(.lbss) + +.lrodata + *(.lrodata) + +.ldata + *(.ldata) + +.stab + *(.stab) + +.stabstr + *(.stabstr) + +.stab.excl + *(.stab.excl) + +.stab.exclstr + *(.stab.exclstr) + +.stab.index + *(.stab.index) + +.stab.indexstr + *(.stab.indexstr) + +.comment 0x0000000000000000 0x56 + *(.comment) + .comment 0x0000000000000000 0x2b foo.o + .comment 0x000000000000002b 0x2b bar.o + +.note.GNU-stack + 0x0000000000000000 0x0 + .note.GNU-stack + 0x0000000000000000 0x0 foo.o + .note.GNU-stack + 0x0000000000000000 0x0 bar.o + +.gnu.build.attributes + *(.gnu.build.attributes) + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges + *(.debug_aranges) + +.debug_pubnames + *(.debug_pubnames) + +.debug_info + *(.debug_info) + +.debug_abbrev + *(.debug_abbrev) + +.debug_line + *(.debug_line) + +.debug_frame + *(.debug_frame) + +.debug_str + *(.debug_str) + +.debug_loc + *(.debug_loc) + +.debug_macinfo + *(.debug_macinfo) + +.debug_weaknames + *(.debug_weaknames) + +.debug_funcnames + *(.debug_funcnames) + +.debug_typenames + *(.debug_typenames) + +.debug_varnames + *(.debug_varnames) + +.debug_pubtypes + *(.debug_pubtypes) + +.debug_ranges + *(.debug_ranges) + +.debug_macro + *(.debug_macro) + +.debug_addr + *(.debug_addr) + +.gnu.attributes + *(.gnu.attributes) +OUTPUT(merge-1.o elf64-x86-64) diff --git a/Semestr 4/ask/lista8/merge-2.map b/Semestr 4/ask/lista8/merge-2.map new file mode 100644 index 0000000..2677803 --- /dev/null +++ b/Semestr 4/ask/lista8/merge-2.map @@ -0,0 +1,301 @@ + +Merging program properties + + +Discarded input sections + + .note.gnu.property + 0x0000000000000000 0x20 foo.o + +Memory Configuration + +Name Origin Length Attributes +*default* 0x0000000000000000 0xffffffffffffffff + +Linker script and memory map + +LOAD bar.o +LOAD foo.o + +.interp + *(.interp) + +.note.gnu.property + 0x0000000000000000 0x20 + .note.gnu.property + 0x0000000000000000 0x20 bar.o + +.note.gnu.build-id + *(.note.gnu.build-id) + +.hash + *(.hash) + +.gnu.hash + *(.gnu.hash) + +.dynsym + *(.dynsym) + +.dynstr + *(.dynstr) + +.gnu.version + *(.gnu.version) + +.gnu.version_d + *(.gnu.version_d) + +.gnu.version_r + *(.gnu.version_r) + +.rela.init + *(.rela.init) + +.rela.text + *(.rela.text) + +.rela.fini + *(.rela.fini) + +.rela.rodata + *(.rela.rodata) + +.rela.data.rel.ro + *(.rela.data.rel.ro) + +.rela.data + *(.rela.data) + +.rela.tdata + *(.rela.tdata) + +.rela.tbss + *(.rela.tbss) + +.rela.ctors + *(.rela.ctors) + +.rela.dtors + *(.rela.dtors) + +.rela.got + *(.rela.got) + +.rela.bss + *(.rela.bss) + +.rela.ldata + *(.rela.ldata) + +.rela.lbss + *(.rela.lbss) + +.rela.lrodata + *(.rela.lrodata) + +.rela.ifunc + *(.rela.ifunc) + +.rela.plt + *(.rela.plt) + +.init + *(SORT_NONE(.init)) + +.plt + *(.plt) + +.plt.got + *(.plt.got) + +.plt.sec + *(.plt.sec) + +.text 0x0000000000000000 0x0 + *(.text .stub) + .text 0x0000000000000000 0x0 bar.o + .text 0x0000000000000000 0x0 foo.o + *(.gnu.warning) + +.fini + *(SORT_NONE(.fini)) + +.rodata + *(.rodata) + +.rodata1 + *(.rodata1) + +.eh_frame_hdr + *(.eh_frame_hdr) + +.eh_frame + *(.eh_frame) + +.gcc_except_table + *(.gcc_except_table) + +.gnu_extab + *(.gnu_extab*) + +.exception_ranges + *(.exception_ranges) + +.eh_frame + *(.eh_frame) + +.gnu_extab + *(.gnu_extab) + +.gcc_except_table + *(.gcc_except_table) + +.exception_ranges + *(.exception_ranges) + +.tdata + *(.tdata) + +.tbss + *(.tbss) + +.jcr + *(.jcr) + +.dynamic + *(.dynamic) + +.got + *(.got) + +.got.plt + *(.got.plt) + +.data 0x0000000000000000 0x10 + *(.data) + .data 0x0000000000000000 0x4 bar.o + 0x0000000000000000 bar + *fill* 0x0000000000000004 0x4 + .data 0x0000000000000008 0x8 foo.o + 0x0000000000000008 foo + +.data1 + *(.data1) + +.bss 0x0000000000000000 0x31 + *(.bss) + .bss 0x0000000000000000 0x1e bar.o + 0x0000000000000000 dead + *fill* 0x000000000000001e 0x2 + .bss 0x0000000000000020 0x11 foo.o + 0x0000000000000020 code + +.lbss + *(.lbss) + +.lrodata + *(.lrodata) + +.ldata + *(.ldata) + +.stab + *(.stab) + +.stabstr + *(.stabstr) + +.stab.excl + *(.stab.excl) + +.stab.exclstr + *(.stab.exclstr) + +.stab.index + *(.stab.index) + +.stab.indexstr + *(.stab.indexstr) + +.comment 0x0000000000000000 0x56 + *(.comment) + .comment 0x0000000000000000 0x2b bar.o + .comment 0x000000000000002b 0x2b foo.o + +.note.GNU-stack + 0x0000000000000000 0x0 + .note.GNU-stack + 0x0000000000000000 0x0 bar.o + .note.GNU-stack + 0x0000000000000000 0x0 foo.o + +.gnu.build.attributes + *(.gnu.build.attributes) + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges + *(.debug_aranges) + +.debug_pubnames + *(.debug_pubnames) + +.debug_info + *(.debug_info) + +.debug_abbrev + *(.debug_abbrev) + +.debug_line + *(.debug_line) + +.debug_frame + *(.debug_frame) + +.debug_str + *(.debug_str) + +.debug_loc + *(.debug_loc) + +.debug_macinfo + *(.debug_macinfo) + +.debug_weaknames + *(.debug_weaknames) + +.debug_funcnames + *(.debug_funcnames) + +.debug_typenames + *(.debug_typenames) + +.debug_varnames + *(.debug_varnames) + +.debug_pubtypes + *(.debug_pubtypes) + +.debug_ranges + *(.debug_ranges) + +.debug_macro + *(.debug_macro) + +.debug_addr + *(.debug_addr) + +.gnu.attributes + *(.gnu.attributes) +OUTPUT(merge-2.o elf64-x86-64) diff --git a/Semestr 4/ask/lista8/mismatch-a.c b/Semestr 4/ask/lista8/mismatch-a.c new file mode 100644 index 0000000..39436f2 --- /dev/null +++ b/Semestr 4/ask/lista8/mismatch-a.c @@ -0,0 +1,7 @@ +/* mismatch-a.c */ +void p2(void); + +int main() { + p2(); + return 0; +} diff --git a/Semestr 4/ask/lista8/mismatch-b.c b/Semestr 4/ask/lista8/mismatch-b.c new file mode 100644 index 0000000..451d5b3 --- /dev/null +++ b/Semestr 4/ask/lista8/mismatch-b.c @@ -0,0 +1,8 @@ +/* mismatch-b.c */ +#include + +char main; + +void p2() { + printf("0x%x\n", main); +} diff --git a/Semestr 4/ask/lista8/odd.c b/Semestr 4/ask/lista8/odd.c new file mode 100644 index 0000000..c32961e --- /dev/null +++ b/Semestr 4/ask/lista8/odd.c @@ -0,0 +1,8 @@ +int is_even(long n); + +int is_odd(long n) { + if (n == 0) + return 0; + else + return is_even(n - 1); +} diff --git a/Semestr 4/ask/lista8/relo3.c b/Semestr 4/ask/lista8/relo3.c new file mode 100644 index 0000000..6aca7b6 --- /dev/null +++ b/Semestr 4/ask/lista8/relo3.c @@ -0,0 +1,15 @@ +int relo3(int val) { + switch (val) { + case 100: + return val; + case 101: + return val + 1; + case 103: + case 104: + return val + 3; + case 105: + return val + 5; + default: + return val + 6; + } +} diff --git a/Semestr 4/ask/lista8/start.c b/Semestr 4/ask/lista8/start.c new file mode 100644 index 0000000..a875ace --- /dev/null +++ b/Semestr 4/ask/lista8/start.c @@ -0,0 +1,8 @@ +int is_even(long); + +void _start(void) { + asm volatile( + "syscall" + : /* no output */ + : "a" (0x3c), "D" (is_even(42))); +} diff --git a/Semestr 4/ask/lista8/str-a.c b/Semestr 4/ask/lista8/str-a.c new file mode 100644 index 0000000..3b0fb36 --- /dev/null +++ b/Semestr 4/ask/lista8/str-a.c @@ -0,0 +1,10 @@ +#include + +char *somestr(void); + +int main(void) { + char *s = somestr(); + s[5] = '\0'; + puts(s); + return 0; +} diff --git a/Semestr 4/ask/lista8/str-b.c b/Semestr 4/ask/lista8/str-b.c new file mode 100644 index 0000000..50101cb --- /dev/null +++ b/Semestr 4/ask/lista8/str-b.c @@ -0,0 +1,9 @@ +#include +#include + +char *somestr(void) { + char *buf = malloc(sizeof("Hello, world!")); + strcpy(buf, "Hello, world!"); + return buf; +} + diff --git a/Semestr 4/ask/lista8/swap.c b/Semestr 4/ask/lista8/swap.c new file mode 100644 index 0000000..e1966fd --- /dev/null +++ b/Semestr 4/ask/lista8/swap.c @@ -0,0 +1,18 @@ +extern int buf[]; + +int *bufp0 = &buf[0]; +static int *bufp1; + +static void incr() { + static int count = 0; + count++; +} + +void swap() { + int temp; + incr(); + bufp1 = &buf[1]; + temp = *bufp0; + *bufp0 = *bufp1; + *bufp1 = temp; +} diff --git a/Semestr 4/ask/lista9/gadget.s b/Semestr 4/ask/lista9/gadget.s new file mode 100644 index 0000000..6d60a63 --- /dev/null +++ b/Semestr 4/ask/lista9/gadget.s @@ -0,0 +1,16 @@ + .global gadget + + .text + +# rax: 0x3c +# rdi: 0 +# rdx: {NULL, ...} +# rsi: path + '\n' +gadget: + dec %rax # rax: 0x3c -> 0x3b (sys_execve) + mov %rdx, %rsi # rsi: argv = {NULL} + mov %rdi, %rdx # rdx: envp = NULL + lea 16(%rsp),%rdi # rdi: path + ret + +# vim: ft=gas diff --git a/Semestr 4/ask/lista9/lazy.c b/Semestr 4/ask/lista9/lazy.c new file mode 100644 index 0000000..fb08cf7 --- /dev/null +++ b/Semestr 4/ask/lista9/lazy.c @@ -0,0 +1,7 @@ +#include + +int main(void) { + puts("first time"); + puts("second time"); + return 0; +} diff --git a/Semestr 4/ask/lista9/lista_9.tgz b/Semestr 4/ask/lista9/lista_9.tgz new file mode 100644 index 0000000..5e5c6f4 Binary files /dev/null and b/Semestr 4/ask/lista9/lista_9.tgz differ diff --git a/Semestr 4/ask/lista9/relo3.c b/Semestr 4/ask/lista9/relo3.c new file mode 100644 index 0000000..6aca7b6 --- /dev/null +++ b/Semestr 4/ask/lista9/relo3.c @@ -0,0 +1,15 @@ +int relo3(int val) { + switch (val) { + case 100: + return val; + case 101: + return val + 1; + case 103: + case 104: + return val + 3; + case 105: + return val + 5; + default: + return val + 6; + } +} diff --git a/Semestr 4/ask/lista9/ropex.c b/Semestr 4/ask/lista9/ropex.c new file mode 100644 index 0000000..dbeae12 --- /dev/null +++ b/Semestr 4/ask/lista9/ropex.c @@ -0,0 +1,31 @@ +#include +#include +#include + +/* Get string from stdin */ +void readline(FILE *in, char *p) { + int c; + while (true) { + c = fgetc(in); + if (c == EOF || c == '\n') + break; + *p++ = c; + } + *p = '\0'; +} + +void echo(FILE *in) { + char buf[48]; + readline(in, buf); + puts(buf); +} + +int main(int argc, char *argv[]) { + FILE *in = NULL; + if (argc == 2) + in = fopen(argv[1], "rb"); + if (in == NULL) + in = stdin; + echo(in); + return 0; +} diff --git a/Semestr 4/ask/lista9/ropex.in (1).txt b/Semestr 4/ask/lista9/ropex.in (1).txt new file mode 100644 index 0000000..902773e --- /dev/null +++ b/Semestr 4/ask/lista9/ropex.in (1).txt @@ -0,0 +1,7 @@ +00000000: dead c0de dead c0de dead c0de dead c0de ................ +00000010: dead c0de dead c0de dead c0de dead c0de ................ +00000020: dead c0de dead c0de dead c0de dead c0de ................ +00000030: dead c0de dead c0de 731c 4000 0000 0000 ................ +00000040: f422 4000 0000 0000 0000 0000 0000 0000 ................ +00000050: 2f75 7372 2f62 696e 2f70 7974 686f 6e32 /usr/bin/python2 +00000060: 000a ................ diff --git a/Semestr 4/ask/lista9/ropex.in.txt b/Semestr 4/ask/lista9/ropex.in.txt new file mode 100644 index 0000000..8deabfe --- /dev/null +++ b/Semestr 4/ask/lista9/ropex.in.txt @@ -0,0 +1,7 @@ +00000000: dead c0de dead c0de dead c0de dead c0de ................ +00000010: dead c0de dead c0de dead c0de dead c0de ................ +00000020: dead c0de dead c0de dead c0de dead c0de ................ +00000030: dead c0de dead c0de 671d 4000 0000 0000 ................ +00000040: 8e44 4900 0000 0000 0000 0000 0000 0000 ................ +00000050: 2f75 7372 2f62 696e 2f6e 7961 6e63 6174 /usr/bin/nyancat +00000060: 000a ................ \ No newline at end of file diff --git a/Semestr 4/ask/lista9/ropex.map b/Semestr 4/ask/lista9/ropex.map new file mode 100644 index 0000000..4bd12a5 --- /dev/null +++ b/Semestr 4/ask/lista9/ropex.map @@ -0,0 +1,511 @@ +Archive member included to satisfy reference by file (symbol) + +/usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) + /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (__libc_csu_init) + +Merging program properties + +Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (0x3) and gadget.o (not found) +Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (not found) and /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) (0x3) +Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (not found) and /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o (0x3) +Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (not found) and /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o (0x3) + +As-needed library included to satisfy reference by file (symbol) + +libc.so.6 ropex.o (fopen@@GLIBC_2.2.5) + +Discarded input sections + + .note.gnu.property + 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + .note.GNU-stack + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + .note.gnu.property + 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o + .note.GNU-stack + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o + .note.GNU-stack + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o + .note.gnu.property + 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o + .note.GNU-stack + 0x0000000000000000 0x0 ropex.o + .note.gnu.property + 0x0000000000000000 0x20 ropex.o + .note.GNU-stack + 0x0000000000000000 0x0 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) + .note.gnu.property + 0x0000000000000000 0x20 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) + .note.GNU-stack + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o + .note.gnu.property + 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o + .note.gnu.property + 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o + .note.GNU-stack + 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o + +Memory Configuration + +Name Origin Length Attributes +*default* 0x0000000000000000 0xffffffffffffffff + +Linker script and memory map + +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o +LOAD ropex.o +LOAD gadget.o +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc_s.so +START GROUP +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libgcc_s.so.1 +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a +END GROUP +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libc.so +START GROUP +LOAD /lib/x86_64-linux-gnu/libc.so.6 +LOAD /usr/lib/x86_64-linux-gnu/libc_nonshared.a +LOAD /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 +END GROUP +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc_s.so +START GROUP +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libgcc_s.so.1 +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a +END GROUP +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o +LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o + [!provide] PROVIDE (__executable_start = SEGMENT_START ("text-segment", 0x0)) + 0x00000000000002a8 . = (SEGMENT_START ("text-segment", 0x0) + SIZEOF_HEADERS) + +.interp 0x00000000000002a8 0x1c + *(.interp) + .interp 0x00000000000002a8 0x1c /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + +.note.gnu.build-id + 0x00000000000002c4 0x24 + *(.note.gnu.build-id) + .note.gnu.build-id + 0x00000000000002c4 0x24 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + +.note.ABI-tag 0x00000000000002e8 0x20 + .note.ABI-tag 0x00000000000002e8 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + +.hash + *(.hash) + +.gnu.hash 0x0000000000000308 0x28 + *(.gnu.hash) + .gnu.hash 0x0000000000000308 0x28 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + +.dynsym 0x0000000000000330 0x108 + *(.dynsym) + .dynsym 0x0000000000000330 0x108 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + +.dynstr 0x0000000000000438 0xaf + *(.dynstr) + .dynstr 0x0000000000000438 0xaf /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + +.gnu.version 0x00000000000004e8 0x16 + *(.gnu.version) + .gnu.version 0x00000000000004e8 0x16 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + +.gnu.version_d 0x0000000000000500 0x0 + *(.gnu.version_d) + .gnu.version_d + 0x0000000000000500 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + +.gnu.version_r 0x0000000000000500 0x30 + *(.gnu.version_r) + .gnu.version_r + 0x0000000000000500 0x30 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + +.rela.dyn 0x0000000000000530 0xd8 + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + .rela.text 0x0000000000000530 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + .rela.data.rel.ro + 0x0000000000000530 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + .rela.data.rel.local + 0x0000000000000530 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + .rela.got 0x0000000000000548 0x78 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + .rela.bss 0x00000000000005c0 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*) + *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*) + *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*) + *(.rela.ifunc) + .rela.ifunc 0x00000000000005d8 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + .rela.fini_array + 0x00000000000005d8 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + .rela.init_array + 0x00000000000005f0 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + +.rela.plt 0x0000000000000608 0x60 + *(.rela.plt) + .rela.plt 0x0000000000000608 0x60 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + *(.rela.iplt) + 0x0000000000001000 . = ALIGN (CONSTANT (MAXPAGESIZE)) + +.init 0x0000000000001000 0x1b + *(SORT_NONE(.init)) + .init 0x0000000000001000 0x16 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o + 0x0000000000001000 _init + .init 0x0000000000001016 0x5 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o + +.plt 0x0000000000001020 0x50 + *(.plt) + .plt 0x0000000000001020 0x50 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + 0x0000000000001030 puts@@GLIBC_2.2.5 + 0x0000000000001040 __stack_chk_fail@@GLIBC_2.4 + 0x0000000000001050 fgetc@@GLIBC_2.2.5 + 0x0000000000001060 fopen@@GLIBC_2.2.5 + *(.iplt) + +.plt.got 0x0000000000001070 0x8 + *(.plt.got) + .plt.got 0x0000000000001070 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + 0x0000000000001070 __cxa_finalize@@GLIBC_2.2.5 + +.plt.sec + *(.plt.sec) + +.text 0x0000000000001080 0x235 + *(.text.unlikely .text.*_unlikely .text.unlikely.*) + *(.text.exit .text.exit.*) + *(.text.startup .text.startup.*) + *(.text.hot .text.hot.*) + *(SORT_BY_NAME(.text.sorted.*)) + *(.text .stub .text.* .gnu.linkonce.t.*) + .text 0x0000000000001080 0x2f /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + 0x0000000000001080 _start + .text 0x00000000000010af 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o + *fill* 0x00000000000010af 0x1 + .text 0x00000000000010b0 0xb9 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o + .text 0x0000000000001169 0xbb ropex.o + 0x0000000000001169 readline + 0x00000000000011a3 echo + 0x00000000000011e7 main + .text 0x0000000000001224 0xf gadget.o + 0x0000000000001224 gadget + *fill* 0x0000000000001233 0xd + .text 0x0000000000001240 0x75 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) + 0x0000000000001240 __libc_csu_init + 0x00000000000012b0 __libc_csu_fini + .text 0x00000000000012b5 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o + .text 0x00000000000012b5 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o + *(.gnu.warning) + +.fini 0x00000000000012b8 0xd + *(SORT_NONE(.fini)) + .fini 0x00000000000012b8 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o + 0x00000000000012b8 _fini + .fini 0x00000000000012c0 0x5 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o + [!provide] PROVIDE (__etext = .) + [!provide] PROVIDE (_etext = .) + [!provide] PROVIDE (etext = .) + 0x0000000000002000 . = ALIGN (CONSTANT (MAXPAGESIZE)) + 0x0000000000002000 . = SEGMENT_START ("rodata-segment", (ALIGN (CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 0x1)))) + +.rodata 0x0000000000002000 0x7 + *(.rodata .rodata.* .gnu.linkonce.r.*) + .rodata.cst4 0x0000000000002000 0x4 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + 0x0000000000002000 _IO_stdin_used + .rodata.str1.1 + 0x0000000000002004 0x3 ropex.o + +.rodata1 + *(.rodata1) + +.eh_frame_hdr 0x0000000000002008 0x34 + *(.eh_frame_hdr) + .eh_frame_hdr 0x0000000000002008 0x34 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + 0x0000000000002008 __GNU_EH_FRAME_HDR + *(.eh_frame_entry .eh_frame_entry.*) + +.eh_frame 0x0000000000002040 0xd0 + *(.eh_frame) + .eh_frame 0x0000000000002040 0x30 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + 0x2c (size before relaxing) + *fill* 0x0000000000002070 0x0 + .eh_frame 0x0000000000002070 0x28 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + 0x40 (size before relaxing) + .eh_frame 0x0000000000002098 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + 0x30 (size before relaxing) + .eh_frame 0x00000000000020b0 0x5c /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) + 0x78 (size before relaxing) + .eh_frame 0x000000000000210c 0x4 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o + *(.eh_frame.*) + +.gcc_except_table + *(.gcc_except_table .gcc_except_table.*) + +.gnu_extab + *(.gnu_extab*) + +.exception_ranges + *(.exception_ranges*) + 0x0000000000003da0 . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)) + +.eh_frame + *(.eh_frame) + *(.eh_frame.*) + +.gnu_extab + *(.gnu_extab) + +.gcc_except_table + *(.gcc_except_table .gcc_except_table.*) + +.exception_ranges + *(.exception_ranges*) + +.tdata 0x0000000000003da0 0x0 + [!provide] PROVIDE (__tdata_start = .) + *(.tdata .tdata.* .gnu.linkonce.td.*) + +.tbss + *(.tbss .tbss.* .gnu.linkonce.tb.*) + *(.tcommon) + +.preinit_array 0x0000000000003da0 0x0 + [!provide] PROVIDE (__preinit_array_start = .) + *(.preinit_array) + [!provide] PROVIDE (__preinit_array_end = .) + +.init_array 0x0000000000003da0 0x8 + 0x0000000000003da0 PROVIDE (__init_array_start = .) + *(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)) + *(.init_array EXCLUDE_FILE(*crtend?.o *crtend.o *crtbegin?.o *crtbegin.o) .ctors) + .init_array 0x0000000000003da0 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o + 0x0000000000003da8 PROVIDE (__init_array_end = .) + +.fini_array 0x0000000000003da8 0x8 + [!provide] PROVIDE (__fini_array_start = .) + *(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)) + *(.fini_array EXCLUDE_FILE(*crtend?.o *crtend.o *crtbegin?.o *crtbegin.o) .dtors) + .fini_array 0x0000000000003da8 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o + [!provide] PROVIDE (__fini_array_end = .) + +.ctors + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT_BY_NAME(.ctors.*)) + *(.ctors) + +.dtors + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT_BY_NAME(.dtors.*)) + *(.dtors) + +.jcr + *(.jcr) + +.data.rel.ro 0x0000000000003db0 0x0 + *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) + *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) + .data.rel.ro 0x0000000000003db0 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + +.dynamic 0x0000000000003db0 0x1f0 + *(.dynamic) + .dynamic 0x0000000000003db0 0x1f0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + 0x0000000000003db0 _DYNAMIC + +.got 0x0000000000003fa0 0x60 + *(.got.plt) + .got.plt 0x0000000000003fa0 0x38 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + 0x0000000000003fa0 _GLOBAL_OFFSET_TABLE_ + *(.igot.plt) + *(.got) + .got 0x0000000000003fd8 0x28 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + *(.igot) + 0x0000000000004000 . = DATA_SEGMENT_RELRO_END (., 0x0) + +.data 0x0000000000004000 0x10 + *(.data .data.* .gnu.linkonce.d.*) + .data 0x0000000000004000 0x4 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + 0x0000000000004000 data_start + 0x0000000000004000 __data_start + .data 0x0000000000004004 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o + .data 0x0000000000004004 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o + *fill* 0x0000000000004004 0x4 + .data.rel.local + 0x0000000000004008 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o + 0x0000000000004008 __dso_handle + .data 0x0000000000004010 0x0 ropex.o + .data 0x0000000000004010 0x0 gadget.o + .data 0x0000000000004010 0x0 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) + .data 0x0000000000004010 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o + .data 0x0000000000004010 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o + +.tm_clone_table + 0x0000000000004010 0x0 + .tm_clone_table + 0x0000000000004010 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o + .tm_clone_table + 0x0000000000004010 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o + +.data1 + *(.data1) + 0x0000000000004010 _edata = . + [!provide] PROVIDE (edata = .) + 0x0000000000004010 . = . + 0x0000000000004010 __bss_start = . + +.bss 0x0000000000004010 0x10 + *(.dynbss) + *fill* 0x0000000000004010 0x0 + .dynbss 0x0000000000004010 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + 0x0000000000004010 stdin@@GLIBC_2.2.5 + *(.bss .bss.* .gnu.linkonce.b.*) + .bss 0x0000000000004018 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o + .bss 0x0000000000004018 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o + .bss 0x0000000000004018 0x1 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o + .bss 0x0000000000004019 0x0 ropex.o + .bss 0x0000000000004019 0x0 gadget.o + .bss 0x0000000000004019 0x0 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) + .bss 0x0000000000004019 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o + .bss 0x0000000000004019 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o + *(COMMON) + 0x0000000000004020 . = ALIGN ((. != 0x0)?0x8:0x1) + *fill* 0x0000000000004019 0x7 + +.lbss + *(.dynlbss) + *(.lbss .lbss.* .gnu.linkonce.lb.*) + *(LARGE_COMMON) + 0x0000000000004020 . = ALIGN (0x8) + 0x0000000000004020 . = SEGMENT_START ("ldata-segment", .) + +.lrodata + *(.lrodata .lrodata.* .gnu.linkonce.lr.*) + +.ldata 0x0000000000006020 0x0 + *(.ldata .ldata.* .gnu.linkonce.l.*) + 0x0000000000006020 . = ALIGN ((. != 0x0)?0x8:0x1) + 0x0000000000006020 . = ALIGN (0x8) + 0x0000000000004020 _end = . + [!provide] PROVIDE (end = .) + 0x0000000000006020 . = DATA_SEGMENT_END (.) + +.stab + *(.stab) + +.stabstr + *(.stabstr) + +.stab.excl + *(.stab.excl) + +.stab.exclstr + *(.stab.exclstr) + +.stab.index + *(.stab.index) + +.stab.indexstr + *(.stab.indexstr) + +.comment 0x0000000000000000 0x2a + *(.comment) + .comment 0x0000000000000000 0x2a /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o + 0x2b (size before relaxing) + .comment 0x000000000000002a 0x2b ropex.o + .comment 0x000000000000002a 0x2b /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o + +.gnu.build.attributes + *(.gnu.build.attributes .gnu.build.attributes.*) + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges 0x0000000000000000 0x30 + *(.debug_aranges) + .debug_aranges + 0x0000000000000000 0x30 ropex.o + +.debug_pubnames + *(.debug_pubnames) + +.debug_info 0x0000000000000000 0x49e + *(.debug_info .gnu.linkonce.wi.*) + .debug_info 0x0000000000000000 0x49e ropex.o + +.debug_abbrev 0x0000000000000000 0x19b + *(.debug_abbrev) + .debug_abbrev 0x0000000000000000 0x19b ropex.o + +.debug_line 0x0000000000000000 0x188 + *(.debug_line .debug_line.* .debug_line_end) + .debug_line 0x0000000000000000 0x188 ropex.o + +.debug_frame 0x0000000000000000 0xa8 + *(.debug_frame) + .debug_frame 0x0000000000000000 0xa8 ropex.o + +.debug_str 0x0000000000000000 0x2f4 + *(.debug_str) + .debug_str 0x0000000000000000 0x2f4 ropex.o + 0x333 (size before relaxing) + +.debug_loc 0x0000000000000000 0x254 + *(.debug_loc) + .debug_loc 0x0000000000000000 0x254 ropex.o + +.debug_macinfo + *(.debug_macinfo) + +.debug_weaknames + *(.debug_weaknames) + +.debug_funcnames + *(.debug_funcnames) + +.debug_typenames + *(.debug_typenames) + +.debug_varnames + *(.debug_varnames) + +.debug_pubtypes + *(.debug_pubtypes) + +.debug_ranges + *(.debug_ranges) + +.debug_macro + *(.debug_macro) + +.debug_addr + *(.debug_addr) + +.gnu.attributes + *(.gnu.attributes) + +/DISCARD/ + *(.note.GNU-stack) + *(.gnu_debuglink) + *(.gnu.lto_*) +OUTPUT(ropex elf64-x86-64) diff --git a/Semestr 4/ask/lista9/test.c b/Semestr 4/ask/lista9/test.c new file mode 100644 index 0000000..1dae111 --- /dev/null +++ b/Semestr 4/ask/lista9/test.c @@ -0,0 +1,7 @@ +void foobar() {} + +static const struct { + char a[3]; int b; long c; float pi; +} baz = { "abc", 42, -3, 1.4142 }; + +long array[100]; \ No newline at end of file diff --git a/Semestr 4/ask/lista9/test.s b/Semestr 4/ask/lista9/test.s new file mode 100644 index 0000000..5e60585 --- /dev/null +++ b/Semestr 4/ask/lista9/test.s @@ -0,0 +1,50 @@ + .file "test.c" + .text + .globl foobar + .type foobar, @function +foobar: +.LFB0: + .cfi_startproc + endbr64 + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + nop + popq %rbp + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size foobar, .-foobar + .section .rodata + .align 16 + .type baz, @object + .size baz, 24 +baz: + .ascii "abc" + .zero 1 + .long 42 + .quad -3 + .long 1068827777 + .zero 4 + .comm array,800,32 + .ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" + .section .note.GNU-stack,"",@progbits + .section .note.gnu.property,"a" + .align 8 + .long 1f - 0f + .long 4f - 1f + .long 5 +0: + .string "GNU" +1: + .align 8 + .long 0xc0000002 + .long 3f - 2f +2: + .long 0x3 +3: + .align 8 +4: -- cgit v1.2.3