Skip to content

Instantly share code, notes, and snippets.

View KarenWest's full-sized avatar

Karen West KarenWest

View GitHub Profile
@KarenWest
KarenWest / gist:9373354
Created March 5, 2014 18:24
number of sections in an object file using bfd data structure on Linux using C
My question is in regard to bfd's and how the number of sections work in the following code. The code and the dumps inside the gdb debugger of the bfd structure and it's section structure within it are displayed below. I also included the data structure definitions for the bfd and bfd->sections below. My question is: why when I run this code (executable is called getsections): getsections getsections.o (so pass it the object file for itself) - why is the sections structure blank (all zeroes) and if you look at the bfd->section_count, it has the number 4218960? If you use the Linux command: objdump -h getsections.o, that displays 14 sections (.text, .data, .bss, .rodata, .debug_info, .debug_abbrev, .debug_loc, .debug_aranges, .debug_line, .debug_str, .comment, .comment.SUSE.OPTS, .note-GNU-stack, .eh_frame). I've read what I could find in the BFD documentation on the web, and I'm not sure what I'm doing wrong here since my object file structure is nowhere near what you would see with objdump (14 sections). Any
/*
* ioctl test module --.
*/
#include <linux/module.h>
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/errno.h> /* error codes */
#include <linux/proc_fs.h>
#include <asm/uaccess.h>
#include <linux/tty.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#define MY_MACIG 'G'
#define READ_IOCTL _IOR(MY_MACIG, 0, int)
//#define WRITE_IOCTL _IOW(MY_MACIG, 1, int)
/* attribute structures */
struct ioctl_test_t {
I just started working on homework 2 in rails as you recommended, even though the course is not currently running. After doing the db migrate and db seed, I started the rails server - that seemed to work. However, when I tried to interact with rotten potatoes via my web browser using at the URL line localhost:3000/movies - I received the following error message - perhaps because the course needs to be running? Not sure. I thought you said last week that I should be able to do these assignments I never got to without the course actually going on - so not sure if it is my error or that the course needs to be running - since I did actually try this a few months ago - but before I had gotten the ruby assignment completely working - so had just tried these first few steps for kicks back then - and it worked then without issue - so unless I'm forgetting something - I do think the course needs to be running to try this - but please let me know if I'm wrong here. Here is the error message from my browser at the
module Enumerable
def initialize(seq1, seq2)
puts "Enumerable initialize"
puts "seq1"
puts seq1
puts "seq2"
puts seq2
@seq1 = seq1
@seq2 = seq2
#return @seq1,@seq2
Output from code is in comments at bottom - not sure what I'm doing wrong here, as you will see in
the output.
# -*- coding: utf-8 -*-
=begin
Karen West - Saas1 - homework#1 question #7 - April 7th, 2013
HW 1-7: Iterators, Blocks, Yield
Given two collections (of possibly different lengths), we want to get the Cartesian product of the sequences. A Cartesian product is a sequence that enumerates every possible pair from the two collections, where the pair consists of one element from each collection. For example, the Cartesian product (denoted by ×) of the sequences a = [:a, :b, :c] and b = [4, 5] is:
def computeQValueFromValues(self, state, action):
"""
Compute the Q-value of action in state from the
value function stored in self.values.
"""
"*** YOUR CODE HERE ***"
#for this state and action, get list of probabilities for
#the legal transitions to new states for this state
#if "North" or "South" is action --returns (northState,1-self.noise),
#followed by (westState, self.noise/2.0) and (eastState, self.noise/2)
def computeQValueFromValues(self, state, action):
"""
Compute the Q-value of action in state from the
value function stored in self.values.
"""
"*** YOUR CODE HERE ***"
#for this state and action, get list of probabilities for
#the legal transitions to new states for this state
#if "North" or "South" is action --returns (northState,1-self.noise),
#followed by (westState, self.noise/2.0) and (eastState, self.noise/2)
Question -- error at bottom here - ruby interpreter error
# -*- coding: utf-8 -*-
=begin
Karen West - Saas1 - homework#1 question #7 - April 7th, 2013
HW 1-7: Iterators, Blocks, Yield
Given two collections (of possibly different lengths), we want to get the Cartesian product of the sequences. A Cartesian product is a sequence that enumerates every possible pair from the two collections, where the pair consists of one element from each collection. For example, the Cartesian product (denoted by ×) of the sequences a = [:a, :b, :c] and b = [4, 5] is:
a × b = [ [:a,4], [:a,5], [:b,4], [:b,5], [:c,4], [:c,5] ]
# -*- coding: utf-8 -*-
=begin
Karen West - April 7th, 2013 - homework#1 question#6
HW 1-6: Advanced OOP, Metaprogramming, Open Classes and Duck Typing
Part A — Currency conversion (ELLS 3.11): Extend the currency-conversion
example from lecture so that code such as the following will work:
5.dollars.in(:euros)
10.euros.in(:rupees)