Sunday, February 6, 2022

LLVM

LLVM code snippet:

 call <2 x i64> @read128(<2 x i64>* %1) 

 at above code snippet we are mapping vector to api parameters to map it accordningly in c, we need to create datatype through attribute option as below:

typedef long long test_uint128_t __attribute__((__vector_size__(16), __aligned__(1)));

 

To list the passes an API main() in a  file hello.c goes through:

clang -c -mllvm -print-before-all -mllvm -print-after-all hello.c -mllvm -filter-print-funcs=main

 

Tell clang to emit debug info by adding the -g flag:

clang -Os -S -emit-llvm -g addition.c
 if you are interested where this line came from:

%cmp = icmp sgt i32 %x, 10, !dbg !21


You have to look for the debug entry !21:

!21 = !DILocation(line: 4, column: 9, scope: !22)

line 9 is source line numbe.

 

 

 

 

 

reference:

https://stackoverflow.com/questions/45142289/how-to-map-c-function-to-llvm-ir




Wednesday, December 1, 2021

IPV6

 Three ways of learning IPv6 address

Static, SLAAC, DHCPv6.

Default gateway is learnt through SLAAC negotiation from router through RA msgs.

 

References:

https://www.networkacademy.io/ccna/ipv6/stateless-address-autoconfiguration-slaac  -- basic slaac flow is explained in very detail

Wednesday, June 9, 2021

Assembly code

Assembly code with examples:

---

stepi ---  Step each instruction:

 

-----

lea -- assembly code operation

lea    -0x40(%rbp),%rcx
(gdb) info registers rbp
rbp            0x7fd1cd6fc850   0x7fd1cd6fc850
(gdb) info registers rcx
rcx            0x7fd1cd6fc810   140539071547408
(gdb) p/x 0x7fd1cd6fc850- 0x40
$19 = 0x7fd1cd6fc810 

----

lea (%rdi, %rdi, 4), %rax  # set %rax to %rdi + %rdi * 4

(gdb) p/x $rax + $rcx * 8
$14203 = 0x480
(gdb) p/x $rbx
$14197 = 0x480
(gdb) p/x $rax
$14198 = 0x0  
(gdb) p/x $rcx
$14199 = 0x90
 0x0000560e660e05ab <+267>:   lea    (%rax,%rcx,8),%rbx

-----

Display current instruction:

(gdb) disp/i $pc
1: x/i $pc
=> 0x55fc7df2e297 <func [__be_func...]+39>: mov    %rax,%rdi

------

Display 10 instructions from current instruction:

----------

(gdb) x/10i $pc

Monday, March 8, 2021

Virtual Machine

 Loading Centos:

https://getlabsdone.com/10-easy-steps-to-install-centos-7-8-on-vmware-workstation/

Friday, July 31, 2020

Dynamic programming


DATA structures:

m-trees:
https://stackoverflow.com/questions/4872969/practical-use-of-m-way-tree


Reference:
https://www.techiedelight.com/introduction-dynamic-programming/

Wednesday, February 22, 2017

Apple mac

To put back multiples files from Trash:

Open apple script editor and copy paste following code and run.

repeat 5 times --or as many files you have
    tell application "Finder" to open trash --open the trash folder
    tell application "Finder" to activate
    tell application "System Events"
        tell process "Finder"
            delay 0.2 -- adjust delay as needed
            key code 125 --move down to get focus on a file
            key down command --hold command key
            delay 0.2 -- adjust delay as needed
            key code 51 --hit delete
            key up command --release command
        end tell
    end tell
    delay 0.2 -- adjust delay as needed
    tell application "Finder" to close every window --close everything for the next cycle
end repeat

 Flash drive/USB not recognized for macbook pro:

This method solves the issue after the drive is formatted and reconnected to the system. In order to do that, here are the steps;

1 – Press Command + Spacebar and connect the flash drive.

2 – Open Application and click on Disk Utility Option

3 – Select the Flash Drive on the left pane.

4 – Click on Erase button to complete the process                           




Reference:
https://www.remosoftware.com/info/fix-flash-drive-not-recognized-mac-windows
https://forums.macrumors.com/threads/batch-put-back-files-from-trash-to-original-location.1573914/

Monday, May 11, 2015

EAP


On EAP(yet start)


References:
https://sites.google.com/site/amitsciscozone/home/switching/peap---protected-eap-protocol