Thursday, October 14, 2010

To find dependency in Linux dynamic object file/library

linux-bvhg:~> objdump -x `which ffmpeg`

/usr/local/bin/ffmpeg:     file format elf64-x86-64
/usr/local/bin/ffmpeg
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000405360

Program Header:
PHDR off    0x0000000000000040 vaddr 0x0000000000400040 paddr 0x0000000000400040 align 2**3
filesz 0x00000000000001f8 memsz 0x00000000000001f8 flags r-x
INTERP off    0x0000000000000238 vaddr 0x0000000000400238 paddr 0x0000000000400238 align 2**0
filesz 0x000000000000001c memsz 0x000000000000001c flags r--
LOAD off    0x0000000000000000 vaddr 0x0000000000400000 paddr 0x0000000000400000 align 2**21
filesz 0x0000000000017124 memsz 0x0000000000017124 flags r-x
LOAD off    0x00000000000179c8 vaddr 0x00000000006179c8 paddr 0x00000000006179c8 align 2**21
filesz 0x0000000000001e18 memsz 0x00000000000038a0 flags rw-
DYNAMIC off    0x0000000000018d10 vaddr 0x0000000000618d10 paddr 0x0000000000618d10 align 2**3
filesz 0x0000000000000240 memsz 0x0000000000000240 flags rw-
NOTE off    0x0000000000000254 vaddr 0x0000000000400254 paddr 0x0000000000400254 align 2**2
filesz 0x000000000000005c memsz 0x000000000000005c flags r--
EH_FRAME off    0x0000000000015db0 vaddr 0x0000000000415db0 paddr 0x0000000000415db0 align 2**2
filesz 0x0000000000000304 memsz 0x0000000000000304 flags r--
STACK off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3
filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
RELRO off    0x00000000000179c8 vaddr 0x00000000006179c8 paddr 0x00000000006179c8 align 2**0
filesz 0x0000000000001638 memsz 0x0000000000001638 flags r--

Dynamic Section:
NEEDED               libavdevice.so.52
NEEDED               libavfilter.so.1
NEEDED               libavformat.so.52
NEEDED               libavcodec.so.52
NEEDED               libpostproc.so.51
NEEDED               libswscale.so.0
NEEDED               libavcore.so.0
NEEDED               libavutil.so.50
NEEDED               libpthread.so.0
NEEDED               libm.so.6
NEEDED               libc.so.6
INIT                 0x0000000000404670
FINI                 0x00000000004124e8
HASH                 0x00000000004002b0
GNU_HASH             0x0000000000400960
STRTAB               0x0000000000401f48
SYMTAB               0x00000000004009d0
STRSZ                0x0000000000000f0d
SYMENT               0x0000000000000018
DEBUG                0x0000000000000000
PLTGOT               0x0000000000618fe8
PLTRELSZ             0x0000000000001320
PLTREL               0x0000000000000007
JMPREL               0x0000000000403350
RELA                 0x00000000004031a0
RELASZ               0x00000000000001b0
RELAENT              0x0000000000000018
VERNEED              0x0000000000403020
VERNEEDNUM           0x000000000000000b
VERSYM               0x0000000000402e56

Version References:
required from libpostproc.so.51:
0x0826df11 0x00 14 LIBPOSTPROC_51
required from libavcore.so.0:
0x0a34bd40 0x00 12 LIBAVCORE_0
required from libm.so.6:
0x09691a75 0x00 11 GLIBC_2.2.5
required from libavfilter.so.1:
0x0ececed1 0x00 10 LIBAVFILTER_1
required from libavdevice.so.52:
0x07b11f22 0x00 09 LIBAVDEVICE_52
required from libavcodec.so.52:
0x035ff8b2 0x00 08 LIBAVCODEC_52
required from libavutil.so.50:
0x0f818430 0x00 07 LIBAVUTIL_50
required from libswscale.so.0:
0x027973e0 0x00 05 LIBSWSCALE_0
required from libavformat.so.52:
0x0c7032c2 0x00 04 LIBAVFORMAT_52
required from libpthread.so.0:
0x09691a75 0x00 03 GLIBC_2.2.5
required from libc.so.6:
0x0d696917 0x00 13 GLIBC_2.7
0x0d696913 0x00 06 GLIBC_2.3
0x09691a75 0x00 02 GLIBC_2.2.5

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
0 .interp       0000001c  0000000000400238  0000000000400238  00000238  2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .note.ABI-tag 00000020  0000000000400254  0000000000400254  00000254  2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .note.SuSE    00000018  0000000000400274  0000000000400274  00000274  2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .note.gnu.build-id 00000024  000000000040028c  000000000040028c  0000028c  2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .hash         000006b0  00000000004002b0  00000000004002b0  000002b0  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .gnu.hash     0000006c  0000000000400960  0000000000400960  00000960  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 .dynsym       00001578  00000000004009d0  00000000004009d0  000009d0  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 .dynstr       00000f0d  0000000000401f48  0000000000401f48  00001f48  2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 .gnu.version  000001ca  0000000000402e56  0000000000402e56  00002e56  2**1
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 .gnu.version_r 00000180  0000000000403020  0000000000403020  00003020  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .rela.dyn     000001b0  00000000004031a0  00000000004031a0  000031a0  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
11 .rela.plt     00001320  0000000000403350  0000000000403350  00003350  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
12 .init         00000018  0000000000404670  0000000000404670  00004670  2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
13 .plt          00000cd0  0000000000404688  0000000000404688  00004688  2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
14 .text         0000d188  0000000000405360  0000000000405360  00005360  2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
15 .fini         0000000e  00000000004124e8  00000000004124e8  000124e8  2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
16 .rodata       000038b0  0000000000412500  0000000000412500  00012500  2**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
17 .eh_frame_hdr 00000304  0000000000415db0  0000000000415db0  00015db0  2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
18 .eh_frame     0000106c  00000000004160b8  00000000004160b8  000160b8  2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
19 .ctors        00000010  00000000006179c8  00000000006179c8  000179c8  2**3
CONTENTS, ALLOC, LOAD, DATA
20 .dtors        00000010  00000000006179d8  00000000006179d8  000179d8  2**3
CONTENTS, ALLOC, LOAD, DATA
21 .jcr          00000008  00000000006179e8  00000000006179e8  000179e8  2**3
CONTENTS, ALLOC, LOAD, DATA
22 .data.rel.ro  00001310  0000000000617a00  0000000000617a00  00017a00  2**5
CONTENTS, ALLOC, LOAD, DATA
23 .dynamic      00000240  0000000000618d10  0000000000618d10  00018d10  2**3
CONTENTS, ALLOC, LOAD, DATA
24 .got          00000098  0000000000618f50  0000000000618f50  00018f50  2**3
CONTENTS, ALLOC, LOAD, DATA
25 .got.plt      00000678  0000000000618fe8  0000000000618fe8  00018fe8  2**3
CONTENTS, ALLOC, LOAD, DATA
26 .data         00000180  0000000000619660  0000000000619660  00019660  2**5
CONTENTS, ALLOC, LOAD, DATA
27 .bss          00001a88  00000000006197e0  00000000006197e0  000197e0  2**5
ALLOC
28 .comment.SUSE.OPTs 00000006  0000000000000000  0000000000000000  000197e0  2**0
CONTENTS, READONLY
29 .comment      00000042  0000000000000000  0000000000000000  000197e6  2**0
CONTENTS, READONLY
SYMBOL TABLE:
no symbols


Tuesday, October 12, 2010

To test Prime Number

#include <stdio.h>


typedef enum {
    FALSE = 0,
    TRUE = 1
} BOOL;

char *boolstr[] = {"FALSE", "TRUE"};

BOOL is_even(unsigned int k)
{
    if (k % 2) return FALSE;
    return TRUE;
}

BOOL is_prime(unsigned long k, unsigned long *divisor)
{
    unsigned long testnum,testlimit;
    BOOL ret = FALSE;

    if (k == 1) return FALSE; // 1 is neigher prime neither composite
    if (k == 2) return TRUE;
    if (is_even(k)) return FALSE; // even numbers are never prime, except 2
    testlimit = k;
    testnum = 3;
    while (testnum < testlimit) {
        //printf("highest prime divisor=%lu\n",*divisor);
        if ( (k % testnum) == 0)
        {
            *divisor = testnum;
            printf("div=%lu\n", *divisor);
            return FALSE; //return TRUE;
            // k is not prime as it is divisable by l

        }
        testlimit = k/testnum;
        testnum += 2;

    }
    return TRUE;
}


int main()
{
    unsigned long k,divisor;

    divisor=1;
    printf("Enter an integer: ");
    scanf("%lu", &k);
    printf("k=%lu is even? %s\n", k, boolstr[is_even(k)]);
    if (is_prime(k, &divisor))
    {
        printf("k=%lu is prime? %s\n", k, boolstr[TRUE]);
    }
    else
    {
        printf("%lu is NOT prime\n", k);
        //printf("highest prime divisor = %lu\n", divisor);
    }
}

Tuesday, October 5, 2010

3D Entertainment

While 3D televisions are more available in the stores, their price is still high and not many people are getting into it.  Perhaps because there is still few BD 3Dd movies.  But now 3D camcoders are going into the market.  We will see if this change how people buy LCD TVs.

Today, when I went to Costco, the 42" 120 Hz LED 3D TV is already below $2000.

Monday, October 4, 2010

Power consumption and Cost saving of Using Ooma (revised)

After awhile, I observed that this Ooma + router consume less power when the temperature is lower.  In the previous blog, I said the average power when its idling is 27 W @ 25 C, but in the early morning when temperature is lower (at about 20 C), the idling power is only 14 W and 17 W when the handset is off-hook.

Sunday, October 3, 2010

Power consumption and Cost saving of Using Ooma

Devices measured:


  1. Ooma hub
  2. Linksys WRT54g wireless router
  3. Traditional wired phoneset connected to Ooma


Power-meter: Kill-A-Watt EZ

Result:

  • System idle: 27 watt
  • Phone is off hook (dial tone): 30 Watt
  • Phone is dialing: 30 Watt
  • During talk: 30 Watt
  • Check voice mail tru the hub: 28 Watt


How much the electricity cost we pay monthly?
For Northern California, PGE has a chart describing the rate.  The average KWH rate for residential seasonal schedule E-8 is $0.22832 (this is just an average, the actual calculation depends on the tier/how much we consume electricity above its baseline).  So, the maximum KWH for Oma in a day is: 30 Watt * 24 hours = 720 WH = 0.72 KWH.  In a month (30 days) = 21.6 KWH or it costs = $4.32

If we don't subscribe to Ooma premier service, there is no additional cost, so it is the actual monthly cost we pay.  If we subscribe to annual Ooma premier service which $119.99/year, we end up paying: $119.99/12 + $4.32 =  $14.32 (rounded up) per month.

As a comparison, when I subscribed to AT&T landline local service (local unlimited), I paid (total, including all the fees and taxes) $27.15.  This did not include caller-ID and all other features.  It was just bare minimum.  With Ooma premier, besides we get caller-ID, we also get two lines, call forwarding (or simultaneous ringing to another number), broadband voice mail (with MP3 file can be sent to email we specified), and other features.  AT&T could have charged those features for additional $15 or more.

Now, how much we save by using Ooma?  OK, first we need to take to the account the broadband portion used for Ooma.  For example, I pay AT&T U-Verse 10 Mbps/1 Mbps (downstream/upstream) $45 a month.  In average, Ooma uses a fractional bandwidth, which is about 256 Kbps.  The max fraction of cost (hypothetically) is then = 0.256/10 * $45/month = $1.152, or about $1.2/month.  Assume we use Ooma premier, the total monthly cost is then $14.32 + 1.2 = $15.52/month.  The saving is = $27.15 - $15.52 =  $11.63/month.


The price of Ooma hub (including one Ooma scout) is $219.99 (at www.ooma.com) +sales tax (which is 9.25% in my area) or $240.34.  The number of months to recover the cost using the amount of money we save above is then $240.34/$11.63 = 20.66 months, or say 21 months (1.75 years).  After that, the saving we collect is going to our pocket.  If you decide not to use Ooma more than 1.75 years, you won't save any.

Note: the calculation above does not include power consumption of Ooma scout, but I surely is smaller than the hub's.

Wednesday, September 29, 2010

ReadyNAS Duo Internals

This very cool NAS Box runs a version of Linux (I think Debian):

nas-D0-E9-23:/c/home/admin# uname -a
Linux nas-D0-E9-23 2.6.17.8ReadyNAS #1 Tue Jun 9 13:59:28 PDT 2009 padre unknown

nas-D0-E9-23:/c/home/admin# cat /proc/cpuinfo
cpu : Infrant Technologics, Inc. - neon version: 0
fpu : Softfpu
ncpus probed : 1
ncpus active : 1
BogoMips : 186.36
MMU : version: 0
LP : HW.FW version: 0.1
FPGA : fpga000000-0 Configuration: 0
AHB arbitraion : 7
CPU id : 0
Switch : 0
ASIC : IT3107

nas-D0-E9-23:/c/home/admin# lspci
0000:00:17.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 62)
0000:00:17.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 62)
0000:00:17.2 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 65)

nas-D0-E9-23:/proc# fdisk -l /dev/hdc

Disk /dev/hdc: 999.9 GB, 999991611392 bytes
255 heads, 63 sectors/track, 121575 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/hdc1 1 255 2048000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/hdc2 255 287 256000 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/hdc3 287 121575 974242116 5 Extended
/dev/hdc5 287 121575 974242115+ 8e Linux LVM

Compared to my HP desktop machine, this NAS Box is away slower:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Core(TM)2 Quad CPU    Q6600  @ 2.40GHz
stepping        : 11
cpu MHz         : 1600.000
cache size      : 4096 KB
physical id     : 0
siblings        : 4
core id         : 1
cpu cores       : 4
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dt
s acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good aper
fmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm tpr_shadow vnmi flexpriori
ty
bogomips        : 12479.54
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

Despite the fact, I love this new toy!